Prevent buffer overflow when forcibly terminating an escape character.
Obtained from: OpenBSD Note: In the case of a full buffer the OpenBSD implementation will leave in the format string an invalid escape sequence. This appears to be harmless with our C library, but according to C99 this can cause undefined behavior. MFC after: 2 weeks
This commit is contained in:
parent
552b6c0ead
commit
af51ff2234
@ -480,7 +480,9 @@ getformat(void)
|
||||
else if (*p == '%' && *(p+1) == '%')
|
||||
p++;
|
||||
else if (*p == '%' && !*(p+1)) {
|
||||
strcat(format, "%");
|
||||
if (strlcat(format, "%", sizeof(format)) >=
|
||||
sizeof(format))
|
||||
errx(1, "-w word too long");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user