We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent cb65e00 commit 7a098cfCopy full SHA for 7a098cf
usage.c
@@ -9,10 +9,15 @@
9
void vreportf(const char *prefix, const char *err, va_list params)
10
{
11
char msg[4096];
12
- size_t off = strlcpy(msg, prefix, sizeof(msg));
13
char *p, *pend = msg + sizeof(msg);
+ size_t prefix_len = strlen(prefix);
14
15
- p = off < pend - msg ? msg + off : pend - 1;
+ if (sizeof(msg) <= prefix_len) {
16
+ fprintf(stderr, "BUG!!! too long a prefix '%s'\n", prefix);
17
+ abort();
18
+ }
19
+ memcpy(msg, prefix, prefix_len);
20
+ p = msg + prefix_len;
21
if (vsnprintf(p, pend - p, err, params) < 0)
22
*p = '\0'; /* vsnprintf() failed, clip at prefix */
23
0 commit comments