Sfoglia il codice sorgente

civetweb.c: check array limits before access array

[src/civetweb.c:3250]: (style) Array index 'i' is used before limits check.
[src/civetweb.c:3254]: (style) Array index 'i' is used before limits check.

Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
Danny Al-Gaaf 11 anni fa
parent
commit
741fa81371
1 ha cambiato i file con 2 aggiunte e 2 eliminazioni
  1. 2 2
      src/civetweb.c

+ 2 - 2
src/civetweb.c

@@ -3247,11 +3247,11 @@ int mg_modify_passwords_file(const char *fname, const char *domain,
 
     /* Do not allow control characters like newline in user name and domain.
        Do not allow excessively long names either. */
-    for (i=0; user[i]!=0 && i<255; i++) {
+    for (i=0; i<255 && user[i]!=0; i++) {
         if (iscntrl(user[i])) return 0;
     }
     if (user[i]) return 0;
-    for (i=0; domain[i]!=0 && i<255; i++) {
+    for (i=0; i<255 && domain[i]!=0; i++) {
         if (iscntrl(domain[i])) return 0;
     }
     if (domain[i]) return 0;