Commit 2c9bf8b6 authored by Daniel Salzman's avatar Daniel Salzman

libknot/pkt: return KNOT_ETRAIL instead of KNOT_EMAILF if trailing data

parent e6e62084
......@@ -156,6 +156,8 @@ enum knot_error {
KNOT_NO_PUBLIC_KEY,
KNOT_NO_PRIVATE_KEY,
KNOT_ETRAIL,
KNOT_ERROR_MAX = -501
};
......
......@@ -156,6 +156,8 @@ static const struct error errors[] = {
{ KNOT_NO_PUBLIC_KEY, "no public key" },
{ KNOT_NO_PRIVATE_KEY, "no private key" },
{ KNOT_ETRAIL, "trailing data" },
{ KNOT_ERROR, NULL } /* Terminator */
};
......
......@@ -852,7 +852,7 @@ int knot_pkt_parse_payload(knot_pkt_t *pkt, unsigned flags)
/* Check for trailing garbage. */
if (pkt->parsed < pkt->size) {
return KNOT_EMALF;
return KNOT_ETRAIL;
}
return KNOT_EOK;
......
......@@ -245,7 +245,9 @@ uint16_t knot_pkt_rr_offset(const knot_pktsection_t *section, uint16_t i);
*
* \param pkt Given packet.
* \param flags Parsing flags (allowed KNOT_PF_KEEPWIRE)
* \return KNOT_EOK, KNOT_EMALF and other errors
* \retval KNOT_EOK if success.
* \retval KNOT_ETRAIL if success but with some trailing data.
* \retval KNOT_EMALF and other errors.
*/
int knot_pkt_parse(knot_pkt_t *pkt, unsigned flags);
......
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