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

Sasha Khapyorsky sashak at voltaire.com
Tue Apr 14 09:15:38 PDT 2009


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)) {
		n = sizeof(buff) - 2;
		break;
	}

(in order to preserve space for new line).

Sasha



More information about the general mailing list