On Thu, Nov 18, 2004, Roland Dreier <[EMAIL PROTECTED]> wrote:
> It's extremely unlikely, but:
> 
> +     char name[8];
> 
> +     sprintf(name, "ib_mad%d", port_num);
> 
> if port_num >= 10, this will overflow the buffer.  Since a device
> could conceivably have up to 255 ports (although an HCA with hundreds
> of ports is rather far-fetched, and we only create one port for a
> switch), I would suggest doing
> 
>       char name[sizeof "ib_mad123"];

You mean

        char name[sizeof "ib_mad123" + 1];

right? :)

Otherwise we'll limit the name to < 100 ports (yes, yes, nitpicking)

> and
> 
>       snprintf(name, sizeof name, "ib_mad%d", port_num);
> 
> for correctness and (mostly) ease of auditing.

I agree completely.

JE

_______________________________________________
openib-general mailing list
[EMAIL PROTECTED]
http://openib.org/mailman/listinfo/openib-general

To unsubscribe, please visit http://openib.org/mailman/listinfo/openib-general

Reply via email to