walters / rpms / nfs-utils

Forked from rpms/nfs-utils 6 years ago
Clone
9fa08e5
commit bcd0fcaf0966c546da5043be700587f73174ae25
9fa08e5
Author: NeilBrown <neilb@suse.de>
9fa08e5
Date:   Tue Feb 26 13:57:39 2008 -0500
9fa08e5
9fa08e5
    If validateascii is passed a string containing only non-zero 7bit
9fa08e5
    values, then the loop with exit with i == len, and the following
9fa08e5
    test will access beyond the end of the array.
9fa08e5
    
9fa08e5
    So add an extra test to fix this.
9fa08e5
    
9fa08e5
    Found by Marcus Meissner <meissner@novell.com>.
9fa08e5
    
9fa08e5
    Signed-off-by: NeilBrown <neilb@suse.de>
9fa08e5
    Signed-off-by: Steve Dickson <steved@redhat.com>
9fa08e5
9fa08e5
diff --git a/utils/idmapd/idmapd.c b/utils/idmapd/idmapd.c
9fa08e5
index 355c6e1..6b5971c 100644
9fa08e5
--- a/utils/idmapd/idmapd.c
9fa08e5
+++ b/utils/idmapd/idmapd.c
9fa08e5
@@ -848,7 +848,7 @@ validateascii(char *string, u_int32_t len)
9fa08e5
 			return (-1);
9fa08e5
 	}
9fa08e5
 
9fa08e5
-	if (string[i] != '\0')
9fa08e5
+	if ((i >= len) || string[i] != '\0')
9fa08e5
 		return (-1);
9fa08e5
 
9fa08e5
 	return (i + 1);