Skip to content
Permalink
Browse files

Fix popt compilation with gcc 8 (-Wformat-overflow)

```
popt/popthelp.c: In function ‘singleOptionHelp.isra.7’:
popt/popthelp.c:343:29: error: ‘%d’ directive writing between 1 and 11
bytes into a region of size between 0 and 10 [-Werror=format-overflow=]
  sprintf(format, "%%.%ds\n%%%ds", (int) (ch - help), indentLength);
                             ^~
popt/popthelp.c:343:18: note: directive argument in the range
[-2147483643, 2147483647]
  sprintf(format, "%%.%ds\n%%%ds", (int) (ch - help), indentLength);
                  ^~~~~~~~~~~~~~~
popt/popthelp.c:343:2: note: ‘sprintf’ output between 9 and 29 bytes
into a destination of size 16
  sprintf(format, "%%.%ds\n%%%ds", (int) (ch - help), indentLength);
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
```
  • Loading branch information...
rmatev committed May 14, 2019
1 parent 5bb67e5 commit a8615a59611617a1cc9f07e1fd063b74f6001886
Showing with 1 addition and 1 deletion.
  1. +1 −1 popt/popthelp.c
@@ -332,7 +332,7 @@ static void singleOptionHelp(FILE * fp, int maxLeftCol,
/*@-boundsread@*/
while (helpLength > lineLength) {
const char * ch;
char format[16];
char format[30];

ch = help + lineLength - 1;
while (ch > help && !isspace(*ch)) ch--;

0 comments on commit a8615a5

Please sign in to comment.
You can’t perform that action at this time.