* util/hostdisk.c (make_device_name): Fix buffer length
calculations.
This commit is contained in:
parent
e25b5a8c6c
commit
5c5bf96ae6
2 changed files with 18 additions and 2 deletions
|
@ -1,3 +1,9 @@
|
|||
2009-04-14 John Stanley <jpsinthemix@verizon.net>
|
||||
David S. Miller <davem@davemloft.net>
|
||||
|
||||
* util/hostdisk.c (make_device_name): Fix buffer length
|
||||
calculations.
|
||||
|
||||
2009-04-14 Felix Zielcke <fzielcke@z-51.de>
|
||||
|
||||
* util/hostdisk.c [__FreeBSD__ || __FreeBSD_kernel__]: Include
|
||||
|
|
|
@ -656,11 +656,21 @@ make_device_name (int drive, int dos_part, int bsd_part)
|
|||
char *p;
|
||||
|
||||
if (dos_part >= 0)
|
||||
len += 1 + ((dos_part + 1) / 10);
|
||||
{
|
||||
/* Add in char length of dos_part+1 */
|
||||
int tmp = dos_part + 1;
|
||||
len++;
|
||||
while ((tmp /= 10) != 0)
|
||||
len++;
|
||||
}
|
||||
if (bsd_part >= 0)
|
||||
len += 2;
|
||||
|
||||
p = xmalloc (len);
|
||||
/* Length to alloc is: char length of map[drive].drive, plus
|
||||
* char length of (dos_part+1) or of bsd_part, plus
|
||||
* 2 for the comma and a null/end of string (\0)
|
||||
*/
|
||||
p = xmalloc (len + 2);
|
||||
sprintf (p, "%s", map[drive].drive);
|
||||
|
||||
if (dos_part >= 0)
|
||||
|
|
Loading…
Reference in a new issue