Browse Source

Protect against ctype macros.

Manuel Novoa III 23 years ago
parent
commit
d2be3a1d01
1 changed files with 6 additions and 4 deletions
  1. 6 4
      libc/stdio/scanf.c

+ 6 - 4
libc/stdio/scanf.c

@@ -346,8 +346,9 @@ va_list ap;
 					goto nextfmt;
 				}
 				if (p-spec > 3) { /* skip white space if not c or [ */
-					while (isspace(scan_getc_nw(&sc)))
-						{}
+					do {
+						i = scan_getc_nw(&sc);
+					} while (isspace(i));
 					scan_ungetc(&sc);
 				}
 				if (p-spec < 5) { /* [,c,s - string conversions */
@@ -588,8 +589,9 @@ va_list ap;
 			/* Unrecognized specifier! */
 			goto RETURN_cnt;
 		} if (isspace(*fmt)) {	/* Consume all whitespace. */
-			while (isspace(scan_getc_nw(&sc)))
-				{}
+			do {
+				i = scan_getc_nw(&sc);
+			} while (isspace(i));
 		} else {				/* Match the current fmt char. */
 		matchchar:
 			if (scan_getc_nw(&sc) != *fmt) {