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

wmaker: remove intermediate strcpy in updateWorkspaceMenu (Coverity #50213)

Coverity warned because the 2 strcpy may overflow the target buffer (the
code relies on a constant for the max allowed workspace name length).

As in both cases the temporary copy is not useful because the temp copy
will be strdup'd just after, this patch removes the temporary buffer and
uses directly the string.

Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
This commit is contained in:
Christophe CURIS
2014-11-29 16:35:23 +01:00
committed by Carlos R. Mafra
parent 7bf2565316
commit 8b78681a7f

View File

@@ -948,7 +948,6 @@ static void launchDockedApplication(WAppIcon *btn, Bool withSelection)
static void updateWorkspaceMenu(WMenu *menu, WAppIcon *icon)
{
WScreen *scr = menu->frame->screen_ptr;
char title[MAX_WORKSPACENAME_WIDTH + 1];
int i;
if (!menu || !icon)
@@ -958,15 +957,12 @@ static void updateWorkspaceMenu(WMenu *menu, WAppIcon *icon)
if (i < menu->entry_no) {
if (strcmp(menu->entries[i]->text, scr->workspaces[i]->name) != 0) {
wfree(menu->entries[i]->text);
strcpy(title, scr->workspaces[i]->name);
menu->entries[i]->text = wstrdup(title);
menu->entries[i]->text = wstrdup(scr->workspaces[i]->name);
menu->flags.realized = 0;
}
menu->entries[i]->clientdata = (void *)icon;
} else {
strcpy(title, scr->workspaces[i]->name);
wMenuAddCallback(menu, title, switchWSCommand, (void *)icon);
wMenuAddCallback(menu, scr->workspaces[i]->name, switchWSCommand, (void *)icon);
menu->flags.realized = 0;
}