ia64/linux-2.6.18-xen.hg

changeset 895:20be7f6d414a

pci/guestdev, iomul: use strlcpy()

use strlcpy() to make them robust.

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
author Keir Fraser <keir.fraser@citrix.com>
date Thu Jun 04 10:45:49 2009 +0100 (2009-06-04)
parents 4e5cd2fc45a7
children f59c5daed527
files drivers/pci/guestdev.c drivers/pci/iomulti.c drivers/pci/reserve.c
line diff
     1.1 --- a/drivers/pci/guestdev.c	Thu Jun 04 10:33:52 2009 +0100
     1.2 +++ b/drivers/pci/guestdev.c	Thu Jun 04 10:45:49 2009 +0100
     1.3 @@ -104,8 +104,7 @@ static int __init pci_get_hid_uid(char *
     1.4  	if (len <= 0 || HID_LEN < len)
     1.5  		goto format_err_end;
     1.6  
     1.7 -	strncpy(hid, sp, len);
     1.8 -	hid[len] = '\0';
     1.9 +	strlcpy(hid, sp, len);
    1.10  
    1.11  	if (*ep == '-') { /* no uid */
    1.12  		uid[0] = '\0';
    1.13 @@ -122,8 +121,7 @@ static int __init pci_get_hid_uid(char *
    1.14  	if (len <= 0 || UID_LEN < len)
    1.15  		goto format_err_end;
    1.16  
    1.17 -	strncpy(uid, sp, len);
    1.18 -	uid[len] = '\0';
    1.19 +	strlcpy(uid, sp, len);
    1.20  	return TRUE;
    1.21  
    1.22  format_err_end:
    1.23 @@ -549,7 +547,7 @@ static int __init pci_guestdev_setup(cha
    1.24  {
    1.25  	if (strlen(str) >= COMMAND_LINE_SIZE)
    1.26  		return 0;
    1.27 -	strcpy(guestdev_param, str);
    1.28 +	strlcpy(guestdev_param, str, sizeof(guestdev_param));
    1.29  	return 1;
    1.30  }
    1.31  
     2.1 --- a/drivers/pci/iomulti.c	Thu Jun 04 10:33:52 2009 +0100
     2.2 +++ b/drivers/pci/iomulti.c	Thu Jun 04 10:45:49 2009 +0100
     2.3 @@ -412,8 +412,7 @@ static int pci_is_iomul_dev_param(struct
     2.4  			uint8_t bus;
     2.5  			uint8_t dev;
     2.6  
     2.7 -			strncpy(tmp, p, len);
     2.8 -			*(tmp + len) = '\0';
     2.9 +			strlcpy(tmp, p, len);
    2.10  			if (pci_get_sbd(tmp, &seg, &bus, &dev) == 0 &&
    2.11  			    pci_domain_nr(pdev->bus) == seg &&
    2.12  			    pdev->bus->number == bus &&
    2.13 @@ -437,7 +436,7 @@ static int __init pci_iomul_param_setup(
    2.14  		return 0;
    2.15  
    2.16  	/* parse it after pci bus scanning */
    2.17 -	strncpy(iomul_param, str, sizeof(iomul_param));
    2.18 +	strlcpy(iomul_param, str, sizeof(iomul_param));
    2.19  	return 1;
    2.20  }
    2.21  __setup("guestiomuldev=", pci_iomul_param_setup);
     3.1 --- a/drivers/pci/reserve.c	Thu Jun 04 10:33:52 2009 +0100
     3.2 +++ b/drivers/pci/reserve.c	Thu Jun 04 10:45:49 2009 +0100
     3.3 @@ -135,9 +135,9 @@ unsigned long pci_reserve_size_mem(struc
     3.4  
     3.5  static int __init pci_reserve_setup(char *str)
     3.6  {
     3.7 -	if (strlen(str) > sizeof(pci_reserve_param))
     3.8 +	if (strlen(str) >= sizeof(pci_reserve_param))
     3.9  		return 0;
    3.10 -	strcpy(pci_reserve_param, str);
    3.11 +	strlcpy(pci_reserve_param, str, sizeof(pci_reserve_param));
    3.12  	return 1;
    3.13  }
    3.14  __setup("pci_reserve=", pci_reserve_setup);