***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:03:40 PDT 2009
On Tue, Apr 14, 2009 at 12:15 PM, Sasha Khapyorsky <sashak at voltaire.com> wrote:
> On 10:45 Tue 14 Apr , Hal Rosenstock wrote:
>>
>> Signed-off-by: Hal Rosenstock <hal.rosenstock at gmail.com>
>
> Applied. Thanks. See note below.
>
>> + for (i = 0;
>> + i <= (p_ntci->data_details.ntc_256.dr_trunc_hop & 0x3f);
>> + i++) {
>> + if (i == 0)
>> + n += snprintf(buff + n, sizeof(buff) - n, "%d",
>> + p_ntci->data_details.ntc_256.dr_rtn_path[i]);
>> + else
>> + n += snprintf(buff + n, sizeof(buff) - n, ",%d",
>> + p_ntci->data_details.ntc_256.dr_rtn_path[i]);
>
> 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 ?
-- Hal
>
> Sasha
> _______________________________________________
> general mailing list
> general at lists.openfabrics.org
> http://lists.openfabrics.org/cgi-bin/mailman/listinfo/general
>
> To unsubscribe, please visit http://openib.org/mailman/listinfo/openib-general
>
More information about the general
mailing list