[vlc-commits] [Git][videolan/vlc][master] 2 commits: hpack: track vector size separately
Jean-Baptiste Kempf (@jbk)
gitlab at videolan.org
Tue Nov 24 13:51:31 UTC 2026
Jean-Baptiste Kempf pushed to branch master at VideoLAN / VLC
Commits:
2ea30229 by Rémi Denis-Courmont at 2026-11-24T14:39:01+01:00
hpack: track vector size separately
Fixes #30217.
Reported-by: Anthropic and Ada Logics
- - - - -
e463a04c by Rémi Denis-Courmont at 2026-11-24T14:39:01+01:00
h2frame: do not allocate zero-byte array
Avoids ambiguous realloc() semantics.
Fixes #30254.
Reported-by: Anthropic and Ada Logics
- - - - -
2 changed files:
- modules/access/http/h2frame.c
- modules/access/http/hpack.c
Changes:
=====================================
modules/access/http/h2frame.c
=====================================
@@ -24,6 +24,7 @@
#include <assert.h>
#include <stdbool.h>
+#include <stdckdint.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
@@ -501,18 +502,20 @@ static void vlc_h2_parse_headers_start(struct vlc_h2_parser *p,
static int vlc_h2_parse_headers_append(struct vlc_h2_parser *p,
const uint8_t *data, size_t len)
{
+ size_t newlen;
+
assert(p->headers.sid != 0);
- if (p->headers.len + len > 65536)
+ if (ckd_add(&newlen, p->headers.len, len) || newlen > 65536)
return vlc_h2_parse_error(p, VLC_H2_INTERNAL_ERROR);
- uint8_t *buf = realloc(p->headers.buf, p->headers.len + len);
+ uint8_t *buf = realloc(p->headers.buf, newlen ? newlen : 1);
if (unlikely(buf == NULL))
return vlc_h2_parse_error(p, VLC_H2_INTERNAL_ERROR);
p->headers.buf = buf;
memcpy(p->headers.buf + p->headers.len, data, len);
- p->headers.len += len;
+ p->headers.len = newlen;
return 0;
}
=====================================
modules/access/http/hpack.c
=====================================
@@ -576,6 +576,7 @@ static int hpack_decode_hdr(struct hpack_decoder *dec,
int hpack_decode(struct hpack_decoder *dec, const uint8_t *data,
size_t length, char *headers[][2], unsigned max)
{
+ size_t hlen = 0;
unsigned count = 0;
while (length > 0)
@@ -589,10 +590,11 @@ int hpack_decode(struct hpack_decoder *dec, const uint8_t *data,
if (name == NULL)
continue;
- if (count < max)
+ if (hlen < max)
{
- headers[count][0] = name;
- headers[count][1] = value;
+ headers[hlen][0] = name;
+ headers[hlen][1] = value;
+ hlen++;
}
else
{
@@ -604,11 +606,11 @@ int hpack_decode(struct hpack_decoder *dec, const uint8_t *data,
return count;
error:
- while (count > 0)
+ while (hlen > 0)
{
- count--;
- free(headers[count][1]);
- free(headers[count][0]);
+ hlen--;
+ free(headers[hlen][1]);
+ free(headers[hlen][0]);
}
return -1;
}
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/bcfee03e6f6f72d2e1512dd4884c5a7bafc91eed...e463a04c9d88e1fca091abe4ede74a3d49309df0
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/bcfee03e6f6f72d2e1512dd4884c5a7bafc91eed...e463a04c9d88e1fca091abe4ede74a3d49309df0
You're receiving this email because of your account on code.videolan.org. Manage all notifications: https://code.videolan.org/-/profile/notifications | Help: https://code.videolan.org/help
More information about the vlc-commits
mailing list