1
0
mirror of https://github.com/gryf/wmaker.git synced 2025-12-19 12:28:22 +01:00

wmaker: fix possible buffer overrun with filename for Icon Chooser (Coverity #50218)

As pointed by Coverity, there is a possible (yet improbable) buffer overrun
when building the list of files to be used in the Icon Chooser dialog.

Better safe than sorry, let's use the safer function to build the complete
name, and add a little message to the user in case of problem so at least
he can know something was not right.

Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
This commit is contained in:
Christophe CURIS
2014-11-29 16:35:21 +01:00
committed by Carlos R. Mafra
parent aa8ade1ef1
commit 7542451a04

View File

@@ -592,9 +592,13 @@ static void listPixmaps(WScreen *scr, WMList *lPtr, const char *path)
if (strcmp(dentry->d_name, ".") == 0 || strcmp(dentry->d_name, "..") == 0)
continue;
strcpy(pbuf, apath);
strcat(pbuf, "/");
strcat(pbuf, dentry->d_name);
if (wstrlcpy(pbuf, apath, sizeof(pbuf)) >= sizeof(pbuf) ||
wstrlcat(pbuf, "/", sizeof(pbuf)) >= sizeof(pbuf) ||
wstrlcat(pbuf, dentry->d_name, sizeof(pbuf)) >= sizeof(pbuf)) {
wwarning(_("full path for file \"%s\" in \"%s\" is longer than %ld bytes, skipped"),
dentry->d_name, path, sizeof(pbuf) - 1);
continue;
}
if (stat(pbuf, &statb) < 0)
continue;