Don't overflow format

2005-08-23  Tollef Fog Heen  <tfheen@err.no>

	* 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
This commit is contained in:
Tollef Fog Heen 2005-08-23 11:38:33 +00:00
parent 53accfa62d
commit cf48f83724
2 changed files with 9 additions and 3 deletions

View file

@ -1,3 +1,10 @@
2005-08-23 Tollef Fog Heen <tfheen@err.no>
* 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 <tfheen@err.no>
* check/check-cflags, check/check-define-variable,

View file

@ -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);