mirror of
https://github.com/gryf/wmaker.git
synced 2025-12-19 12:28:22 +01:00
Fix possible missing NUL at end of string
There are were a few uses of 'strncpy' that could lead to a missing NUL, resulting in possible garbage being displayed. As suggested by Tamas, use 'wstrlcpy' instead
This commit is contained in:
committed by
Carlos R. Mafra
parent
e499f31a4e
commit
e01d14abe4
@@ -3400,9 +3400,8 @@ char *generateNewFilename(char *curName)
|
|||||||
|
|
||||||
newName = wmalloc(baseLen + 16);
|
newName = wmalloc(baseLen + 16);
|
||||||
strncpy(newName, curName, baseLen);
|
strncpy(newName, curName, baseLen);
|
||||||
newName[baseLen] = 0;
|
|
||||||
|
|
||||||
sprintf(&newName[baseLen], " {%i}", n + 1);
|
snprintf(&newName[baseLen], 16, " {%i}", n + 1);
|
||||||
|
|
||||||
return newName;
|
return newName;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2005,7 +2005,7 @@ static int getKeybind(WScreen * scr, WDefaultEntry * entry, WMPropList * value,
|
|||||||
return True;
|
return True;
|
||||||
}
|
}
|
||||||
|
|
||||||
strncpy(buf, val, MAX_SHORTCUT_LENGTH);
|
wstrlcpy(buf, val, MAX_SHORTCUT_LENGTH);
|
||||||
|
|
||||||
b = (char *)buf;
|
b = (char *)buf;
|
||||||
|
|
||||||
|
|||||||
@@ -424,7 +424,7 @@ static Bool addShortcut(char *file, char *shortcutDefinition, WMenu * menu, WMen
|
|||||||
|
|
||||||
ptr = wmalloc(sizeof(Shortcut));
|
ptr = wmalloc(sizeof(Shortcut));
|
||||||
|
|
||||||
strncpy(buf, shortcutDefinition, MAX_SHORTCUT_LENGTH);
|
wstrlcpy(buf, shortcutDefinition, MAX_SHORTCUT_LENGTH);
|
||||||
b = (char *)buf;
|
b = (char *)buf;
|
||||||
|
|
||||||
/* get modifiers */
|
/* get modifiers */
|
||||||
|
|||||||
@@ -157,9 +157,9 @@ static WUserMenuData *convertShortcuts(WScreen * scr, WMPropList * shortcut)
|
|||||||
for (i = 0, j = 0; i < keycount; i++) {
|
for (i = 0, j = 0; i < keycount; i++) {
|
||||||
data->key[j].modifier = 0;
|
data->key[j].modifier = 0;
|
||||||
if (WMIsPLArray(shortcut)) {
|
if (WMIsPLArray(shortcut)) {
|
||||||
strncpy(buf, WMGetFromPLString(WMGetFromPLArray(shortcut, i)), MAX_SHORTCUT_LENGTH);
|
wstrlcpy(buf, WMGetFromPLString(WMGetFromPLArray(shortcut, i)), MAX_SHORTCUT_LENGTH);
|
||||||
} else {
|
} else {
|
||||||
strncpy(buf, WMGetFromPLString(shortcut), MAX_SHORTCUT_LENGTH);
|
wstrlcpy(buf, WMGetFromPLString(shortcut), MAX_SHORTCUT_LENGTH);
|
||||||
}
|
}
|
||||||
b = (char *)buf;
|
b = (char *)buf;
|
||||||
|
|
||||||
|
|||||||
@@ -749,7 +749,7 @@ void wWorkspaceMenuUpdate(WScreen * scr, WMenu * menu)
|
|||||||
i = scr->workspace_count - (menu->entry_no - 2);
|
i = scr->workspace_count - (menu->entry_no - 2);
|
||||||
ws = menu->entry_no - 2;
|
ws = menu->entry_no - 2;
|
||||||
while (i > 0) {
|
while (i > 0) {
|
||||||
strncpy(title, scr->workspaces[ws]->name, MAX_WORKSPACENAME_WIDTH);
|
wstrlcpy(title, scr->workspaces[ws]->name, MAX_WORKSPACENAME_WIDTH);
|
||||||
|
|
||||||
entry = wMenuAddCallback(menu, title, switchWSCommand, (void *)ws);
|
entry = wMenuAddCallback(menu, title, switchWSCommand, (void *)ws);
|
||||||
entry->flags.indicator = 1;
|
entry->flags.indicator = 1;
|
||||||
|
|||||||
Reference in New Issue
Block a user