public inbox for cygwin-apps@cygwin.com
 help / color / mirror / Atom feed
From: Jon Turney <jon.turney@dronecode.org.uk>
To: "cygwin-apps@cygwin.com" <cygwin-apps@cygwin.com>
Subject: Re: [PATCH setup] Avoid stringop-overflow warning with gcc8
Date: Sat, 13 Oct 2018 12:50:00 -0000	[thread overview]
Message-ID: <c759d781-5a22-81b0-cd89-b3206cb40edf@dronecode.org.uk> (raw)
In-Reply-To: <20181012155839.GG7872@calimero.vinschen.de>

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."

  reply	other threads:[~2018-10-13 12:50 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-12 15:44 Jon Turney
2018-10-12 15:58 ` Corinna Vinschen
2018-10-13 12:50   ` Jon Turney [this message]
2018-10-13 14:36     ` Corinna Vinschen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=c759d781-5a22-81b0-cd89-b3206cb40edf@dronecode.org.uk \
    --to=jon.turney@dronecode.org.uk \
    --cc=cygwin-apps@cygwin.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).