ICMPv6: fix RPL DAGID printing (GH #418)

Allow an extra byte in the buffer for snprintf()'s null character,
otherwise it does not work as intended (issue spotted by Gisle Vanem on
Windows, where snprintf() behaviour seems to be different). Update the
tests.
This commit is contained in:
Denis Ovsienko 2015-01-03 07:24:12 +00:00
parent af7c82332e
commit d0fab6bf83
4 changed files with 4 additions and 4 deletions

View File

@ -660,7 +660,7 @@ rpl_format_dagid(char dagid_str[65], const u_char *dagid)
if(isprint(dagid[i])) {
*d++ = dagid[i];
} else {
snprintf(d,4,"0x%02x", dagid[i]);
snprintf(d,5,"0x%02x", dagid[i]); /* 4 + null char */
d += 4;
}
}

View File

@ -1 +1 @@
IP6 (hlim 64, next-header ICMPv6 (58) payload length: 24) fe80::216:3eff:fe11:3424 > ff02::1: [icmp6 sum ok] ICMP6, RPL, (CLR)Destination Advertisement Object [dagid:pandora is fun0x0,seq:1,instance:1,Dagid,40]
IP6 (hlim 64, next-header ICMPv6 (58) payload length: 24) fe80::216:3eff:fe11:3424 > ff02::1: [icmp6 sum ok] ICMP6, RPL, (CLR)Destination Advertisement Object [dagid:pandora is fun0x0al,seq:1,instance:1,Dagid,40]

View File

@ -1 +1 @@
IP6 (hlim 64, next-header ICMPv6 (58) payload length: 56) fe80::216:3eff:fe11:3424 > fe80::216:3eff:fe11:3424: [icmp6 sum ok] ICMP6, RPL, (CLR)Destination Advertisement Object [dagid:T10x0,seq:10,instance:42,Dagid,40] opt:rpltarget len:25 opt:pad0 opt:pad0 opt:pad0 opt:pad0 opt:pad0 opt:pad0 opt:pad0
IP6 (hlim 64, next-header ICMPv6 (58) payload length: 56) fe80::216:3eff:fe11:3424 > fe80::216:3eff:fe11:3424: [icmp6 sum ok] ICMP6, RPL, (CLR)Destination Advertisement Object [dagid:T10x000x000x000x000x000x000x000x000x000x000x000x000x000x00,seq:10,instance:42,Dagid,40] opt:rpltarget len:25 opt:pad0 opt:pad0 opt:pad0 opt:pad0 opt:pad0 opt:pad0 opt:pad0

View File

@ -1 +1 @@
IP6 (hlim 64, next-header ICMPv6 (58) payload length: 56) fe80::216:3eff:fe11:3424 > fe80::216:3eff:fe11:3424: [icmp6 sum ok] ICMP6, RPL, (CLR)Destination Advertisement Object [dagid:T10x0,seq:10,instance:42,Dagid,40] opt:rpltarget len:25 0x0000: 0080 2001 0db8 0001 0000 0216 3eff fe11 0x0010: 3424 0000 0000 00 opt:pad0 opt:pad0 opt:pad0 opt:pad0 opt:pad0 opt:pad0 opt:pad0
IP6 (hlim 64, next-header ICMPv6 (58) payload length: 56) fe80::216:3eff:fe11:3424 > fe80::216:3eff:fe11:3424: [icmp6 sum ok] ICMP6, RPL, (CLR)Destination Advertisement Object [dagid:T10x000x000x000x000x000x000x000x000x000x000x000x000x000x00,seq:10,instance:42,Dagid,40] opt:rpltarget len:25 0x0000: 0080 2001 0db8 0001 0000 0216 3eff fe11 0x0010: 3424 0000 0000 00 opt:pad0 opt:pad0 opt:pad0 opt:pad0 opt:pad0 opt:pad0 opt:pad0