Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

"fmt2" is supposed to contain a format string. It's supposed to contain the format string from "fmt". That's how it prints the args from "ap".

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");
(Edit for formatting, clarity)


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: