mirror of
https://github.com/profanity-im/profanity.git
synced 2025-02-02 15:08:15 -05:00
Fix gcc warnings for cygwin
strncpy(3) is not so safe function and can lead to mistakes. For example, strncpy(dest, "Profanity", 10); is redundant and leads to problems when someone changes the source string. Different example is when 3rd argument equals to length of the destination buffer. strncpy(3) doesn't terminate string with '\0' when it truncates. Therefore, the destination string becomes corrupted. Zeroize storage for 'nid', so the last byte remains '\0' in case of truncate.
This commit is contained in:
parent
5d8f3f2791
commit
09e12a826f
@ -234,20 +234,21 @@ notify(const char *const message, int timeout, const char *const category)
|
|||||||
#endif
|
#endif
|
||||||
#ifdef PLATFORM_CYGWIN
|
#ifdef PLATFORM_CYGWIN
|
||||||
NOTIFYICONDATA nid;
|
NOTIFYICONDATA nid;
|
||||||
|
memset(&nid, 0, sizeof(nid));
|
||||||
nid.cbSize = sizeof(NOTIFYICONDATA);
|
nid.cbSize = sizeof(NOTIFYICONDATA);
|
||||||
//nid.hWnd = hWnd;
|
//nid.hWnd = hWnd;
|
||||||
nid.uID = 100;
|
nid.uID = 100;
|
||||||
nid.uVersion = NOTIFYICON_VERSION;
|
nid.uVersion = NOTIFYICON_VERSION;
|
||||||
//nid.uCallbackMessage = WM_MYMESSAGE;
|
//nid.uCallbackMessage = WM_MYMESSAGE;
|
||||||
nid.hIcon = LoadIcon(NULL, IDI_APPLICATION);
|
nid.hIcon = LoadIcon(NULL, IDI_APPLICATION);
|
||||||
strncpy(nid.szTip, "Tray Icon", 10);
|
strcpy(nid.szTip, "Tray Icon");
|
||||||
nid.uFlags = NIF_MESSAGE | NIF_ICON | NIF_TIP;
|
nid.uFlags = NIF_MESSAGE | NIF_ICON | NIF_TIP;
|
||||||
Shell_NotifyIcon(NIM_ADD, &nid);
|
Shell_NotifyIcon(NIM_ADD, &nid);
|
||||||
|
|
||||||
// For a Ballon Tip
|
// For a Ballon Tip
|
||||||
nid.uFlags = NIF_INFO;
|
nid.uFlags = NIF_INFO;
|
||||||
strncpy(nid.szInfoTitle, "Profanity", 10); // Title
|
strcpy(nid.szInfoTitle, "Profanity"); // Title
|
||||||
strncpy(nid.szInfo, message, 256); // Copy Tip
|
strncpy(nid.szInfo, message, sizeof(nid.szInfo) - 1); // Copy Tip
|
||||||
nid.uTimeout = timeout; // 3 Seconds
|
nid.uTimeout = timeout; // 3 Seconds
|
||||||
nid.dwInfoFlags = NIIF_INFO;
|
nid.dwInfoFlags = NIIF_INFO;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user