A call to calloc() function to allocate structures in nfsiostat and
cifsiostat wasn't checked for its return code. This call could possibly
fail without ever being noticed.
Mail from Ivana Varekova (varekova@redhat.com) 02/02/2011
Hello, I'm sending 6 patches - 3 for nfsiostat and 3 for cifsiostat
nfsiostat:
nfsiostat2.patch - adds the forgotten test to malloc
(...)
cifsiostat:
cifsiostat2.patch - adds the forgotten test to malloc
(...)
Changes:
xxxx/xx/xx: Version 10.0.0 - Sebastien Godard (sysstat <at> orange.fr)
- * [Jan Kaluza]: Added --debuginfo option to cifsiostat.
- * [Jan Kaluza]: Added --debuginfo option to nfsiostat.
+ * [Ivana Varekova]: Check calloc() return value in cifsiostat
+ and nfsiostat.
+ * [Jan Kaluza]: Added --debuginfo option to cifsiostat and
+ nfsiostat.
* cifsiostat and nfsiostat manual pages updated.
* sysstat_panic function is now defined only in DEBUG mode.
* NLS updated. Ukrainian translation added.
if ((cifs_nr = get_cifs_nr()) > 0) {
cifs_nr += NR_CIFS_PREALLOC;
}
- st_hdr_cifs = (struct io_hdr_stats *) calloc(cifs_nr, IO_HDR_STATS_SIZE);
+ if ((st_hdr_cifs = (struct io_hdr_stats *) calloc(cifs_nr, IO_HDR_STATS_SIZE)) == NULL) {
+ perror("malloc");
+ exit(4);
+ }
/* Allocate structures for number of CIFS directories found */
for (i = 0; i < 2; i++) {
if ((ionfs_nr = get_nfs_mount_nr()) > 0) {
ionfs_nr += NR_NFS_PREALLOC;
}
- st_hdr_ionfs = (struct io_hdr_stats *) calloc(ionfs_nr, IO_HDR_STATS_SIZE);
+ if ((st_hdr_ionfs = (struct io_hdr_stats *) calloc(ionfs_nr, IO_HDR_STATS_SIZE)) == NULL) {
+ perror("malloc");
+ exit(4);
+ }
/* Allocate structures for number of NFS directories found */
for (i = 0; i < 2; i++) {