***SPAM*** Re: [ofa-general] ***SPAM*** Re: [PATCHv2] 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 07:16:24 PDT 2009


On Tue, Apr 14, 2009 at 10:09 AM, Sasha Khapyorsky <sashak at voltaire.com> wrote:
> On 09:42 Tue 14 Apr     , Hal Rosenstock wrote:
>>
>> Signed-off-by: Hal Rosenstock <hal.rosenstock at gmail.com>
>>
>> ---
>> Changes from v1:
>> In trap 144, display local changes as %u rather than %d
>> In trap 256, don't use additional buffer and eliminate buffer copying
>>
>> diff --git a/opensm/opensm/osm_helper.c b/opensm/opensm/osm_helper.c
>
> [snip...]
>
>> +                             n += sprintf(buff + n, "Directed Path Dump of %u hop path:"
>> +                                     "\n\t\t\t\tPath = ",
>> +                                     p_ntci->data_details.ntc_256.dr_trunc_hop & 0x3f);
>> +                             for (i = 0;
>> +                                  i <= (p_ntci->data_details.ntc_256.dr_trunc_hop & 0x3f);
>> +                                  i++) {
>> +                                     if (i == 0)
>> +                                             sprintf(buff + n, "%d",
>> +                                                     p_ntci->data_details.ntc_256.dr_rtn_path[i]);
>> +                                     else
>> +                                             sprintf(buff + n, ",%d",
>> +                                                     p_ntci->data_details.ntc_256.dr_rtn_path[i]);
>
> Should be n += sprintf() in both cases.

Right.

> Also I would recommend to use
> snprintf() instead of sprintf() to prevent possible buf overflow.

It doesn't overflow but I can change it. Also, there are many other
places even in this file where this is not done.

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