You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
i find printf(char *fmt, ...) function may drop the character '%' in the end of any string.
Such as printf("i can print last %\n") can work as expected , but printf("i can print last %") can't.
The error behavior is reason for c = fmt[++i] & 0xff; if (c == 0) break; .
I think it can be changed as
if (c == 0) {
// when string is '\0' , this loop break at 'for' . So it is security using i - 1 in here.
if (fmt[i - 1] == '%') consputc('%');
break;
}
The text was updated successfully, but these errors were encountered:
This is not a bug: % indicates the format for an argument. If you want to print '%', escape the % (i.e., type %%). xv6 printf could give a better error for % followed by a non-format character.
the error function is :
i find
printf(char *fmt, ...)
function may drop the character '%' in the end of any string.Such as
printf("i can print last %\n")
can work as expected , butprintf("i can print last %")
can't.The error behavior is reason for
c = fmt[++i] & 0xff; if (c == 0) break;
.I think it can be changed as
The text was updated successfully, but these errors were encountered: