From: Denis Kenzior <denkenz@gmail.com>
To: ofono@ofono.org
Subject: Re: [PATCH 1/1] src: out of bounds problem in smsutil
Date: Wed, 16 Feb 2011 10:02:58 -0600 [thread overview]
Message-ID: <4D5BF532.7080701@gmail.com> (raw)
In-Reply-To: <4D5BF23A.4080308@stericsson.com>
[-- Attachment #1: Type: text/plain, Size: 1154 bytes --]
Hi Andreas,
>>> }
>>>
>>> /* Space for ranges, commas and terminator null */
>>> - ret = g_new(char, len + nelem);
>>> + ret = g_new0(char, len + nelem + 1);
>>
>> I'm having trouble seeing how the old code was wrong. nelem contains
>> the number of elements. Since the last element does not end with a
>> comma, the use of nelem + 1 in g_new is not necessary. sprintf takes
>> care of adding the terminating null, so using g_new0 is also less
>> efficient.
>>
>> Are you adding channels that are 5 digits long by any chance?
>
> Valgrind complains that we step outside the allocated memory by 1 byte
> since we loop the string with:
>
> while (*topics != '\0')
>
> the allocated memory is the size of the string and any \0 ends up
> outside. At least that's my interpretation.
>
It might be your loop is actually going past the end, not that the
terminating NULL is not within bounds returned from
cbs_topic_ranges_to_string. If the original code was wrong then we
should be seeing valgrind report errors on the cbs code used in
unit/test-sms.c. I'm not seeing this at all.
Regards,
-Denis
next prev parent reply other threads:[~2011-02-16 16:02 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-02-16 12:04 [PATCH 1/1] src: out of bounds problem in smsutil Jessica Nilsson
2011-02-16 15:25 ` Denis Kenzior
2011-02-16 15:50 ` Andreas WESTIN
2011-02-16 16:02 ` Denis Kenzior [this message]
2011-02-16 16:13 ` Andreas WESTIN
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=4D5BF532.7080701@gmail.com \
--to=denkenz@gmail.com \
--cc=ofono@ofono.org \
/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