Hex parsing hardening.

This commit is contained in:
Ian Gulliver
2016-02-26 14:09:37 -08:00
parent e89d30af24
commit e3a372e1ea
11 changed files with 55 additions and 21 deletions

View File

@@ -157,7 +157,9 @@ static bool json_parse_mode_s_short(json_t *in, struct packet *packet, struct js
return false;
}
hex_to_bin(packet->payload, (const uint8_t *) json_string_value(payload), 7);
if (!hex_to_bin(packet->payload, (const uint8_t *) json_string_value(payload), 7)) {
return false;
}
packet->type = PACKET_TYPE_MODE_S_SHORT;
return true;
}
@@ -172,7 +174,9 @@ static bool json_parse_mode_s_long(json_t *in, struct packet *packet, struct jso
return false;
}
hex_to_bin(packet->payload, (const uint8_t *) json_string_value(payload), 14);
if (!hex_to_bin(packet->payload, (const uint8_t *) json_string_value(payload), 14)) {
return false;
}
packet->type = PACKET_TYPE_MODE_S_LONG;
return true;
}