Check values read from file before using.
Fix CID#349504.
Signed-off-by: Sebastien GODARD <sysstat@users.noreply.github.com>
#define EXTRA_DESC_ULL_NR 0 /* Nr of unsigned long long in extra_desc structure */
#define EXTRA_DESC_UL_NR 0 /* Nr of unsigned long in extra_desc structure */
#define EXTRA_DESC_U_NR 6 /* Nr of [unsigned] int in extra_desc structure */
+#define MAX_EXTRA_NR 8192
+#define MAX_EXTRA_SIZE 1024
/* Record type */
/*
return -1;
}
+ if ((xtra_d.extra_nr > MAX_EXTRA_NR) || (xtra_d.extra_size > MAX_EXTRA_SIZE)) {
+#ifdef DEBUG
+ fprintf(stderr, "%s: extra_size=%u extra_nr=%u\n",
+ __FUNCTION__, xtra_d.extra_size, xtra_d.extra_size);
+#endif
+ return -1;
+ }
+
/* Ignore current unknown extra structures */
for (i = 0; i < xtra_d.extra_nr; i++) {
if (lseek(ifd, xtra_d.extra_size, SEEK_CUR) < xtra_d.extra_size)