Skip to content

Commit

Permalink
libopenarc: respect body length in the AMS l tag
Browse files Browse the repository at this point in the history
  • Loading branch information
flowerysong committed Nov 22, 2024
1 parent 3ff4b07 commit a75a7c8
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ All notable changes to this project will be documented in this file.
- Build issues on FreeBSD.
- libopenarc - `arc_free()` accepts NULL.
- libopenarc - `c` is not a required tag in `ARC-Message-Signature`.
- libopenarc = `ARC-Message-Signature` headers covering a limited body length
are processed correctly.

## [1.1.0](https://github.com/flowerysong/OpenARC/releases/tag/v1.1.0) - 2024-11-05

Expand Down
6 changes: 6 additions & 0 deletions libopenarc/arc-canon.c
Original file line number Diff line number Diff line change
Expand Up @@ -1868,6 +1868,12 @@ arc_canon_closebody(ARC_MESSAGE *msg)

arc_canon_buffer(cur, NULL, 0);

if (cur->canon_remain > 0)
{
arc_error(msg, "body length in signature longer than actual body");
return ARC_STAT_SYNTAX;
}

/* finalize */
arc_canon_finalize(cur);

Expand Down
23 changes: 21 additions & 2 deletions libopenarc/arc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1750,7 +1750,15 @@ arc_process_set(ARC_MESSAGE *msg,
}
ARC_FREE(hcopy);

/* test validity of "t", "x", and "i" */
/* test validity of "l", "t", "x", and "i" */
p = arc_param_get(set, "l");
if (p != NULL && !arc_check_uint(p, NULL))
{
arc_error(msg, "invalid \"l\" value in %s data", settype);
set->set_bad = true;
return ARC_STAT_SYNTAX;
}

p = arc_param_get(set, "t");
if (p != NULL)
{
Expand Down Expand Up @@ -2732,6 +2740,7 @@ arc_eoh_verify(ARC_MESSAGE *msg)
{
unsigned int n;
unsigned int hashtype;
uint64_t len;
char *c;
ARC_STAT status;
struct arc_hdrfield *h = NULL;
Expand Down Expand Up @@ -2819,6 +2828,16 @@ arc_eoh_verify(ARC_MESSAGE *msg)
body_canon = ARC_CANON_SIMPLE;
}

c = arc_param_get(h->hdr_data, "l");
if (c != NULL)
{
arc_check_uint(c, &len);
}
else
{
len = -1;
}

status = arc_add_canon(msg, ARC_CANONTYPE_HEADER, hdr_canon, hashtype,
htag, h, (ssize_t) -1, &msg->arc_hdrcanons[n]);

Expand All @@ -2831,7 +2850,7 @@ arc_eoh_verify(ARC_MESSAGE *msg)

/* body, validation */
status = arc_add_canon(msg, ARC_CANONTYPE_BODY, body_canon, hashtype,
NULL, NULL, (ssize_t) -1,
NULL, NULL, (ssize_t) len,
&msg->arc_bodycanons[n]);

if (status != ARC_STAT_OK)
Expand Down

0 comments on commit a75a7c8

Please sign in to comment.