[openib-general] [PATCH] mad: Add port number to MAD thread names
Johannes Erdfelt
johannes at erdfelt.com
Thu Nov 18 10:53:05 PST 2004
On Thu, Nov 18, 2004, Roland Dreier <roland at topspin.com> 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
More information about the general
mailing list