#ifdef HAVE_ZLIB_H
#include <zlib.h> /* crc32 */
#endif
+#ifdef HAVE_LIMITS_H
+#include <limits.h>
+#endif
#include "archive.h"
#ifndef HAVE_ZLIB_H
uint8_t endarc : 1;
uint8_t notused : 5;
- int vol_no;
+ unsigned int vol_no;
};
struct generic_header {
};
struct multivolume {
- int expected_vol_no;
+ unsigned int expected_vol_no;
uint8_t* push_buf;
};
if(!read_var_sized(a, &v, NULL)) {
return ARCHIVE_EOF;
}
-
- rar->main.vol_no = (int) v;
+ if (v > UINT_MAX) {
+ archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
+ "Invalid volume number");
+ return ARCHIVE_FATAL;
+ }
+ rar->main.vol_no = (unsigned int) v;
} else {
rar->main.vol_no = 0;
}
if(ret == ARCHIVE_FATAL) {
return ARCHIVE_EOF;
} else {
+ if(rar->vol.expected_vol_no == UINT_MAX) {
+ archive_set_error(&a->archive,
+ ARCHIVE_ERRNO_FILE_FORMAT, "Header error");
+ return ARCHIVE_FATAL;
+ }
rar->vol.expected_vol_no = rar->main.vol_no + 1;
return ARCHIVE_OK;
}