#define UL_ALIGNMENT_WIDTH SIZEOF_LONG_64BIT
#define U_ALIGNMENT_WIDTH 4
+#define MAP_SIZE(m) ((m[0] * ULL_ALIGNMENT_WIDTH) + \
+ (m[1] * UL_ALIGNMENT_WIDTH) + \
+ (m[2] * U_ALIGNMENT_WIDTH))
+
/*
* Structure for CPU statistics.
* In activity buffer: First structure is for global CPU utilisation ("all").
* Description of the structure containing statistics for the
* given activity (nr of "long long", nr of "long" and nr of "int").
*/
- int types_nr[3];
+ unsigned int types_nr[3];
};
#define FILE_ACTIVITY_SIZE (sizeof(struct file_activity))
* gives the number of "long long" fields composing the structure, then the number
* of "long" fields, then the number of "int" fields.
*/
- int gtypes_nr[3];
+ unsigned int gtypes_nr[3];
/*
* This array has the same meaning as @gtypes_nr[] above, but the values are those
* read from current data file. They may be different from those of @gtypes_nr[]
* because we can read data from a different sysstat version (older or newer).
*/
- int ftypes_nr[3];
+ unsigned int ftypes_nr[3];
/*
* Number of SVG graphs for this activity. The total number of graphs for
* the activity can be greater though if flag AO_GRAPH_PER_ITEM is set, in
int default_file_used = FALSE;
extern struct act_bitmap cpu_bitmap;
-int hdr_types_nr[] = {FILE_HEADER_ULL_NR, FILE_HEADER_UL_NR, FILE_HEADER_U_NR};
-int act_types_nr[] = {FILE_ACTIVITY_ULL_NR, FILE_ACTIVITY_UL_NR, FILE_ACTIVITY_U_NR};
+unsigned int hdr_types_nr[] = {FILE_HEADER_ULL_NR, FILE_HEADER_UL_NR, FILE_HEADER_U_NR};
+unsigned int act_types_nr[] = {FILE_ACTIVITY_ULL_NR, FILE_ACTIVITY_UL_NR, FILE_ACTIVITY_U_NR};
/*
***************************************************************************
* @is64bit TRUE if data come from a 64-bit machine.
***************************************************************************
*/
-void swap_struct(int types_nr[], void *ps, int is64bit)
+void swap_struct(unsigned int types_nr[], void *ps, int is64bit)
{
int i;
uint64_t *x;
* structure expected by current sysstat version).
***************************************************************************
*/
-void remap_struct(int gtypes_nr[], int ftypes_nr[], void *ps, int st_size)
+void remap_struct(unsigned int gtypes_nr[], unsigned int ftypes_nr[],
+ void *ps, unsigned int st_size)
{
int d;
+ /* Sanity check */
+ if (MAP_SIZE(ftypes_nr) > st_size)
+ return;
+
/* Remap [unsigned] long fields */
d = gtypes_nr[0] - ftypes_nr[0];
if (d) {
(fal->types_nr[2] <= act[p]->gtypes_nr[2])))) {
handle_invalid_sa_file(ifd, file_magic, dfile, 0);
}
+ if (MAP_SIZE(fal->types_nr) > fal->size) {
+ handle_invalid_sa_file(ifd, file_magic, dfile, 0);
+ }
for (k = 0; k < 3; k++) {
act[p]->ftypes_nr[k] = fal->types_nr[k];
}
/* TRUE if file's data come from a 64 bit machine */
int arch_64 = FALSE;
-int rec_types_nr[] = {RECORD_HEADER_ULL_NR, RECORD_HEADER_UL_NR, RECORD_HEADER_U_NR};
+unsigned int rec_types_nr[] = {RECORD_HEADER_ULL_NR, RECORD_HEADER_UL_NR, RECORD_HEADER_U_NR};
unsigned int flags = 0;
unsigned int dm_major; /* Device-mapper major number */
unsigned int dm_major; /* Device-mapper major number */
char timestamp[2][TIMESTAMP_LEN];
-int rec_types_nr[] = {RECORD_HEADER_ULL_NR, RECORD_HEADER_UL_NR, RECORD_HEADER_U_NR};
+unsigned int rec_types_nr[] = {RECORD_HEADER_ULL_NR, RECORD_HEADER_UL_NR, RECORD_HEADER_U_NR};
unsigned long avg_count = 0;
* @spmax Array containg the possible new max values for current activity.
***************************************************************************
*/
-void save_extrema(int types_nr[], void *cs, void *ps, unsigned long long itv,
+void save_extrema(unsigned int types_nr[], void *cs, void *ps, unsigned long long itv,
double *spmin, double *spmax, int g_fields[])
{
unsigned long long *lluc, *llup;
"await", "svctm",
"%util"};
int g_fields[] = {0, 1, 2};
- int local_types_nr[] = {1, 0, 0};
+ unsigned int local_types_nr[] = {1, 0, 0};
static double *spmin, *spmax;
static char **out;
static int *outsize;
"rxcmp/s", "txcmp/s", "rxmcst/s",
"%ifutil"};
int g_fields[] = {0, 1, 2, 3, 4, 5, 6};
- int local_types_nr[] = {7, 0, 0};
+ unsigned int local_types_nr[] = {7, 0, 0};
static double *spmin, *spmax;
static char **out;
static int *outsize;
char *g_title[] = {"~kbhugfree", "~kbhugused",
"%hugused"};
int g_fields[] = {0};
- int local_types_nr[] = {0, 1, 0};
+ unsigned int local_types_nr[] = {0, 1, 0};
static double *spmin, *spmax;
static char **out;
static int *outsize;