Bug in accessing via snprintf a NULL string.
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
$Id: scan_devices.c,v 1.12 2005/01/15 16:05:44 rocky Exp $
|
$Id: scan_devices.c,v 1.13 2005/01/18 03:03:56 rocky Exp $
|
||||||
|
|
||||||
Copyright (C) 2004, 2005 Rocky Bernstein <rocky@panix.com>
|
Copyright (C) 2004, 2005 Rocky Bernstein <rocky@panix.com>
|
||||||
Copyright (C) 1998 Monty xiphmont@mit.edu
|
Copyright (C) 1998 Monty xiphmont@mit.edu
|
||||||
@@ -254,16 +254,23 @@ cdda_identify_cooked(const char *dev, int messagedest, char **messages)
|
|||||||
if ( scsi_mmc_get_hwinfo( p_cdio, &hw_info ) ) {
|
if ( scsi_mmc_get_hwinfo( p_cdio, &hw_info ) ) {
|
||||||
unsigned int i_len = strlen(hw_info.psz_vendor)
|
unsigned int i_len = strlen(hw_info.psz_vendor)
|
||||||
+ strlen(hw_info.psz_model)
|
+ strlen(hw_info.psz_model)
|
||||||
+ strlen(hw_info.psz_revision)
|
+ strlen(hw_info.psz_revision) + 3;
|
||||||
+ strlen(description) + 3;
|
|
||||||
|
|
||||||
d->drive_model=malloc( i_len );
|
if (description) {
|
||||||
snprintf( d->drive_model, i_len, "%s%s%s %s",
|
i_len += strlen(description);
|
||||||
hw_info.psz_vendor, hw_info.psz_model, hw_info.psz_revision,
|
d->drive_model=malloc( i_len );
|
||||||
description );
|
snprintf( d->drive_model, i_len, "%s%s%s %s",
|
||||||
|
hw_info.psz_vendor, hw_info.psz_model, hw_info.psz_revision,
|
||||||
|
description );
|
||||||
|
free(description);
|
||||||
|
} else {
|
||||||
|
d->drive_model=malloc( i_len );
|
||||||
|
snprintf( d->drive_model, i_len, "%s%s%s",
|
||||||
|
hw_info.psz_vendor, hw_info.psz_model, hw_info.psz_revision
|
||||||
|
);
|
||||||
|
}
|
||||||
idmessage(messagedest,messages,"\t\tCDROM sensed: %s\n",
|
idmessage(messagedest,messages,"\t\tCDROM sensed: %s\n",
|
||||||
d->drive_model);
|
d->drive_model);
|
||||||
if (description) free(description);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user