From: Tollef Fog Heen Date: Tue, 23 Aug 2005 11:38:33 +0000 (+0000) Subject: Don't overflow format X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=cf48f83724225f7b85b4465b3dbe23d8f7bc5b89;p=pkg-config Don't overflow format 2005-08-23 Tollef Fog Heen * popthelp.c: char format[10] overflowed always with gcc4, so use positional parameters instead. Thanks to Scott James Remnant for pointing me to that solution. Debian #321961, Ubuntu #13950, Freedesktop #2661 --- diff --git a/ChangeLog b/ChangeLog index 506ab99..35fe3fb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2005-08-23 Tollef Fog Heen + + * popthelp.c: char format[10] overflowed always with gcc4, so use + positional parameters instead. Thanks to Scott James Remnant for + pointing me to that solution. Debian #321961, Ubuntu #13950, + Freedesktop #2661 + 2005-08-22 Tollef Fog Heen * check/check-cflags, check/check-define-variable, diff --git a/popthelp.c b/popthelp.c index 265c668..9e1ad1e 100644 --- a/popthelp.c +++ b/popthelp.c @@ -83,7 +83,6 @@ static void singleOptionHelp(FILE * f, int maxLeftCol, const char * help = _(opt->descrip); int helpLength; const char * ch; - char format[10]; char * left = alloca(maxLeftCol + 1); const char * argDescrip = getArgDescrip(opt); @@ -115,8 +114,8 @@ static void singleOptionHelp(FILE * f, int maxLeftCol, while (ch > (help + 1) && isspace(*ch)) ch--; ch++; - sprintf(format, "%%.%ds\n%%%ds", (int) (ch - help), indentLength); - fprintf(f, format, help, " "); + fprintf(f, "%.*s\n%*s", (int) (ch - help), help, indentLength, " "); + help = ch; while (isspace(*help) && *help) help++; helpLength = strlen(help);