[PATCH setup] Avoid stringop-overflow warning with gcc8
Jon Turney
jon.turney@dronecode.org.uk
Sat Oct 13 12:50:00 GMT 2018
On 12/10/2018 16:58, Corinna Vinschen wrote:
> On Oct 12 16:43, Jon Turney wrote:
[...]
>> diff --git a/desktop.cc b/desktop.cc
>> index 927c02f..d003e91 100644
>> --- a/desktop.cc
>> +++ b/desktop.cc
>> @@ -107,7 +107,8 @@ start_menu (const std::string& title, const std::string& target,
>> issystem ? CSIDL_COMMON_PROGRAMS :
>> CSIDL_PROGRAMS, &id);
>> SHGetPathFromIDList (id, path);
>> - strncat (path, "/Cygwin", MAX_PATH);
>> + strncat (path, "/Cygwin", MAX_PATH - strlen(path));
>
> Shouldn't that be
>
> strncat (path, "/Cygwin", MAX_PATH - strlen(path) - 1);
>
> ?
Yes! I have no idea what I was thinking!
Thanks.
> "If src contains n or more bytes, strncat() writes n+1 bytes to dest (n
> from src plus the terminating null byte). Therefore, the size of dest
> must be at least strlen(dest)+n+1."
More information about the Cygwin-apps
mailing list