[hatari-devel] Compiler warnings changes |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/hatari-devel Archives
]
Hi Thomas,
I'm getting compiler warning from your recent zip.c change:
-----------------------------------------------
src/zip.c: In function ‘ZIP_GetFilesDir’:
src/zip.c:327:17: warning: ‘strncpy’ specified bound 256 equals
destination size [-Wstringop-truncation]
327 | strncpy(fentries[i]->d_name, files->names[i],
sizeof(fentries[i]->d_name));
|
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-----------------------------------------------
As it redundantly allows one extra char (one being overwritten with
terminating nil) to be written by strncpy().
Are you not seeing it?
I'm not sure how important it's to avoid it though, as this is not a
real problem:
-----------------------------------------------
- strncpy(fentries[i]->d_name, files->names[i],
sizeof(fentries[i]->d_name));
+ strncpy(fentries[i]->d_name, files->names[i],
sizeof(fentries[i]->d_name)-1);
fentries[i]->d_name[sizeof(fentries[i]->d_name) - 1] = 0;
-----------------------------------------------
- Eero