f->flags |= RSPAMD_ARCHIVE_FILE_ENCRYPTED;
}
+ if (hlen + sizeof(uint16_t) * 2 > (gsize) (extra + extra_len - p)) {
+ /* Truncated or malformed extra field */
+ break;
+ }
p += hlen + sizeof(uint16_t) * 2;
}
uncomp_sz += tmp;
}
+ /*
+ * p advanced past the attrs and optional HIGH_*_SIZE fields
+ * after fname_len was validated above, so re-check it against
+ * the remaining buffer before reading the filename.
+ */
+ if (fname_len > (gsize) (end - p)) {
+ msg_debug_archive("rar archive is invalid (truncated filename)");
+
+ return;
+ }
+
f = g_malloc0(sizeof(*f));
if (flags & 0x200) {
for (i = 0; i < nbits; i++) {
if (mask == 0) {
+ if (p >= end) {
+ return NULL;
+ }
+
avail = *p;
SZ_SKIP_BYTES(1);
mask = 0x80;
uint64_t num_streams,
unsigned int *pdigest_read)
{
+ if (p >= end) {
+ return NULL;
+ }
+
unsigned char all_defined = *p;
uint64_t i;
unsigned int num_defined = 0;
* }
*/
- if (p != NULL) {
+ if (p != NULL && p < end) {
proptype = *p;
SZ_SKIP_BYTES(1);
struct rspamd_archive *arch,
struct rspamd_mime_part *part)
{
+ if (p >= end) {
+ return NULL;
+ }
+
unsigned char t = *p;
SZ_SKIP_BYTES(1);