***SPAM*** Re: [ofa-general] ***SPAM*** Re: [PATCHv3] opensm/osm_helper.c: Add more info for traps 144 and 256-259 in osm_dump_notice

Hal Rosenstock hal.rosenstock at gmail.com
Tue Apr 14 10:27:49 PDT 2009


On Tue, Apr 14, 2009 at 1:03 PM, Hal Rosenstock
<hal.rosenstock at gmail.com> wrote:

<snip...>

>> When snprintf() overflows it returns number of bytes which would be
>> written otherwise, so return value should be checked anyway. So I'm
>> adding this:
>>
>>        if (n >= sizeof(buf)) {
>                               ^^^
>                               buff
>
>>                n = sizeof(buff) - 2;
>>                break;
>>        }
>>
>> (in order to preserve space for new line).
>
> Sounds right.
>
> Doesn't this same issue exist elsewhere in opensm where snprintf is
> used and the return value is not checked in comparison to the size
> supplied ?

I take that back; I audited the other places and they look fine to me.
There are some changes which will make it less likely to fail if some
buffer size is changed though. I will make up a patch for that in due
time.

-- Hal



More information about the general mailing list