Thomas,
I've gone through the truncation errors line by line and they're not fixed in the latest version on github. I'm loathe to increase MAX_INPUT_LENGTH arbitrarily just to remove the errors and it also seems non-trivial to include -Wno-format-truncation to the makefile.
Also, there's an overflow error in improved-edit.c that puzzles me and before I change the size of buf3 I want to get your opinion on this:
Here's the error on compile:
Code:
improved-edit.c: In function ‘parse_edit_action’:
improved-edit.c:371:27: warning: ‘: ’ directive writing 2 bytes into a region of size between 0 and 6 [-Wformat-overflow=]
371 | sprintf(buf3, "%4d: ", (i - 1));
| ^~
In file included from /usr/include/stdio.h:980,
from sysdep.h:69,
from improved-edit.c:7:
In function ‘sprintf’,
inlined from ‘parse_edit_action’ at improved-edit.c:371:9:
/usr/include/x86_64-linux-gnu/bits/stdio2.h:30:10: note: ‘__builtin___sprintf_chk’ output between 7 and 13 bytes into a destination of size 10
30 | return __builtin___sprintf_chk (__s, __USE_FORTIFY_LEVEL - 1,
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
31 | __glibc_objsize (__s), __fmt,
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
32 | __va_arg_pack ());
| ~~~~~~~~~~~~~~~~~
And here's the code from unmodified file from 2018:
Code:
while (s && i <= line_high)
if ((s = strchr(s, '\n')) != NULL) {
i++;
total_len++;
s++;
temp = *s;
*s = '\0';
char buf3[10];
sprintf(buf3, "%4d: ", (i - 1));
strncat(buf, buf3, sizeof(buf) - strlen(buf) - 1);
strncat(buf, t, sizeof(buf) - strlen(buf) - 1);
*s = temp;
t = s;
}
And the code from 2025:
Code:
while (s && i <= line_high)
if ((s = strchr(s, '\n')) != NULL) {
i++;
total_len++;
s++;
temp = *s;
*s = '\0';
char buf3[9];
sprintf(buf3, "%4d: ", (i - 1));
strncat(buf, buf3, sizeof(buf) - strlen(buf) - 1);
strncat(buf, t, sizeof(buf) - strlen(buf) - 1);
*s = temp;
t = s;
}
Am I tilting at windmills or is there a reasonable resolution to these errors?
Thanks.