Commit 0e34b74b authored by Juliusz Chroboczek's avatar Juliusz Chroboczek

Fix parsing of IPv4 prefixes.

parent eb55bc49
...@@ -88,19 +88,28 @@ network_prefix(int ae, int plen, unsigned int omitted, ...@@ -88,19 +88,28 @@ network_prefix(int ae, int plen, unsigned int omitted,
else else
pb = 16; pb = 16;
if(pb > 16)
return -1;
memset(prefix, 0, 16); memset(prefix, 0, 16);
switch(ae) { switch(ae) {
case 0: return 1; case 0: break;
case 1: case 1:
if(pb > omitted && len < pb - omitted) return -1; if(pb > 4 || (pb > omitted && len < pb - omitted)) return -1;
if(omitted) { if (dp == NULL) return -1; memcpy(prefix, dp, omitted); } memcpy(prefix, v4prefix, 12);
if(pb > omitted) memcpy(prefix, v4prefix, 12); if(omitted) {
memcpy(prefix + 12, p, pb); if (dp == NULL || !v4mapped(dp)) return -1;
memcpy(prefix, dp, 12 + omitted);
}
if(pb > omitted) memcpy(prefix + 12 + omitted, p, pb);
break; break;
case 2: case 2:
if(pb > omitted && len < pb - omitted) return -1; if(pb > omitted && len < pb - omitted) return -1;
if(omitted) { if (dp == NULL) return -1; memcpy(prefix, dp, omitted); } if(omitted) {
if (dp == NULL || v4mapped(dp)) return -1;
memcpy(prefix, dp, omitted);
}
if(pb > omitted) memcpy(prefix + omitted, p, pb - omitted); if(pb > omitted) memcpy(prefix + omitted, p, pb - omitted);
break; break;
case 3: case 3:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment