s3-lib: Do not walk past the end of the dos_to_ntstatus_map array
authorAndrew Bartlett <abartlet@samba.org>
Mon, 1 Sep 2014 23:25:07 +0000 (11:25 +1200)
committerAndrew Bartlett <abartlet@samba.org>
Mon, 8 Sep 2014 05:26:34 +0000 (07:26 +0200)
Found by AddressSanitizer

Change-Id: Ic8b3e2599713c37b11324f9ec2d01891f0f287b9
Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Kamen Mazdrashki <kamenim@samba.org>
source3/libsmb/errormap.c

index 22daee4c5c573c0ee34468f01634b98537e39ddc..cc25c7ebae3202c1c4827b17afb8add8396199bd 100644 (file)
@@ -285,7 +285,7 @@ NTSTATUS dos_to_ntstatus(uint8 eclass, uint32 ecode)
 {
        int i;
        if (eclass == 0) return NT_STATUS_OK;
-       for (i=0; NT_STATUS_V(dos_to_ntstatus_map[i].ntstatus); i++) {
+       for (i=0; i < ARRAY_SIZE(dos_to_ntstatus_map); i++) {
                if (eclass == dos_to_ntstatus_map[i].dos_class &&
                    ecode == dos_to_ntstatus_map[i].dos_code) {
                        return dos_to_ntstatus_map[i].ntstatus;