The bug is when getprogname() also returns a string containing a format specifier (e.g. "%s"), which is not expected.
Clearly the fix is:
fprintf(stderr, "%s: ", getprogname()); va_start(ap, fmt); vfprintf(stderr, fmt, ap); va_end(ap); fprintf(stderr, "\n");
The bug is when getprogname() also returns a string containing a format specifier (e.g. "%s"), which is not expected.
Clearly the fix is:
(Edit for formatting, clarity)