mirror of
https://github.com/MidnightCommander/mc
synced 2024-12-23 04:46:55 +03:00
* menu.c (menu_scan_hotkey): Use g_strlcpy() to avoid undefined
behavior when using strcpy() on overlapping strings. * profile.c (GetSetProfile): Likewise. * widget.c (button_scan_hotkey): Likewise. Found by Valgrind.
This commit is contained in:
parent
99a4576359
commit
4014009077
@ -1,3 +1,11 @@
|
||||
2003-09-22 Pavel Roskin <proski@gnu.org>
|
||||
|
||||
* menu.c (menu_scan_hotkey): Use g_strlcpy() to avoid undefined
|
||||
behavior when using strcpy() on overlapping strings.
|
||||
* profile.c (GetSetProfile): Likewise.
|
||||
* widget.c (button_scan_hotkey): Likewise.
|
||||
Found by Valgrind.
|
||||
|
||||
2003-09-13 Pavel Roskin <proski@gnu.org>
|
||||
|
||||
* dlg.c (dlg_replace_widget): Clean rewrite. It was broken
|
||||
|
13
src/menu.c
13
src/menu.c
@ -34,15 +34,14 @@
|
||||
int menubar_visible = 1; /* This is the new default */
|
||||
|
||||
static void
|
||||
menu_scan_hotkey(Menu *menu)
|
||||
menu_scan_hotkey (Menu *menu)
|
||||
{
|
||||
char* cp = strchr (menu->name, '&');
|
||||
char *cp = strchr (menu->name, '&');
|
||||
|
||||
if (cp != NULL && cp[1] != '\0'){
|
||||
strcpy (cp, cp+1);
|
||||
menu->hotkey = tolower(*cp);
|
||||
}
|
||||
else
|
||||
if (cp != NULL && cp[1] != '\0') {
|
||||
g_strlcpy (cp, cp + 1, strlen (cp));
|
||||
menu->hotkey = tolower (*cp);
|
||||
} else
|
||||
menu->hotkey = 0;
|
||||
}
|
||||
|
||||
|
@ -329,7 +329,7 @@ static short GetSetProfile (int set, const char * AppName, char * KeyName,
|
||||
s = GetSetProfileChar (set, AppName, KeyName, Default, FileName);
|
||||
if (!set){
|
||||
ReturnedString [Size-1] = 0;
|
||||
strncpy (ReturnedString, s, Size-1);
|
||||
g_strlcpy (ReturnedString, s, Size-1);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
@ -201,12 +201,12 @@ button_len (const char *text, unsigned int flags)
|
||||
* the button text is g_malloc()ed, we can safely change and shorten it.
|
||||
*/
|
||||
static void
|
||||
button_scan_hotkey(WButton* b)
|
||||
button_scan_hotkey (WButton *b)
|
||||
{
|
||||
char* cp = strchr (b->text, '&');
|
||||
char *cp = strchr (b->text, '&');
|
||||
|
||||
if (cp != NULL && cp[1] != '\0'){
|
||||
strcpy (cp, cp+1);
|
||||
if (cp != NULL && cp[1] != '\0') {
|
||||
g_strlcpy (cp, cp + 1, strlen (cp));
|
||||
b->hotkey = tolower (*cp);
|
||||
b->hotpos = cp - b->text;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user