[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [linux-2.6.18-xen] pci/guestdev, iomul: use strlcpy()



# HG changeset patch
# User Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1244108749 -3600
# Node ID 20be7f6d414a6e26aa614ea9f7f3d29167e2d269
# Parent  4e5cd2fc45a7c4be4a6d0eb48fdd803fdbd0a28d
pci/guestdev, iomul: use strlcpy()

use strlcpy() to make them robust.

Signed-off-by: Isaku Yamahata <yamahata@xxxxxxxxxxxxx>
---
 drivers/pci/guestdev.c |    8 +++-----
 drivers/pci/iomulti.c  |    5 ++---
 drivers/pci/reserve.c  |    4 ++--
 3 files changed, 7 insertions(+), 10 deletions(-)

diff -r 4e5cd2fc45a7 -r 20be7f6d414a drivers/pci/guestdev.c
--- a/drivers/pci/guestdev.c    Thu Jun 04 10:33:52 2009 +0100
+++ b/drivers/pci/guestdev.c    Thu Jun 04 10:45:49 2009 +0100
@@ -104,8 +104,7 @@ static int __init pci_get_hid_uid(char *
        if (len <= 0 || HID_LEN < len)
                goto format_err_end;
 
-       strncpy(hid, sp, len);
-       hid[len] = '\0';
+       strlcpy(hid, sp, len);
 
        if (*ep == '-') { /* no uid */
                uid[0] = '\0';
@@ -122,8 +121,7 @@ static int __init pci_get_hid_uid(char *
        if (len <= 0 || UID_LEN < len)
                goto format_err_end;
 
-       strncpy(uid, sp, len);
-       uid[len] = '\0';
+       strlcpy(uid, sp, len);
        return TRUE;
 
 format_err_end:
@@ -549,7 +547,7 @@ static int __init pci_guestdev_setup(cha
 {
        if (strlen(str) >= COMMAND_LINE_SIZE)
                return 0;
-       strcpy(guestdev_param, str);
+       strlcpy(guestdev_param, str, sizeof(guestdev_param));
        return 1;
 }
 
diff -r 4e5cd2fc45a7 -r 20be7f6d414a drivers/pci/iomulti.c
--- a/drivers/pci/iomulti.c     Thu Jun 04 10:33:52 2009 +0100
+++ b/drivers/pci/iomulti.c     Thu Jun 04 10:45:49 2009 +0100
@@ -412,8 +412,7 @@ static int pci_is_iomul_dev_param(struct
                        uint8_t bus;
                        uint8_t dev;
 
-                       strncpy(tmp, p, len);
-                       *(tmp + len) = '\0';
+                       strlcpy(tmp, p, len);
                        if (pci_get_sbd(tmp, &seg, &bus, &dev) == 0 &&
                            pci_domain_nr(pdev->bus) == seg &&
                            pdev->bus->number == bus &&
@@ -437,7 +436,7 @@ static int __init pci_iomul_param_setup(
                return 0;
 
        /* parse it after pci bus scanning */
-       strncpy(iomul_param, str, sizeof(iomul_param));
+       strlcpy(iomul_param, str, sizeof(iomul_param));
        return 1;
 }
 __setup("guestiomuldev=", pci_iomul_param_setup);
diff -r 4e5cd2fc45a7 -r 20be7f6d414a drivers/pci/reserve.c
--- a/drivers/pci/reserve.c     Thu Jun 04 10:33:52 2009 +0100
+++ b/drivers/pci/reserve.c     Thu Jun 04 10:45:49 2009 +0100
@@ -135,9 +135,9 @@ unsigned long pci_reserve_size_mem(struc
 
 static int __init pci_reserve_setup(char *str)
 {
-       if (strlen(str) > sizeof(pci_reserve_param))
+       if (strlen(str) >= sizeof(pci_reserve_param))
                return 0;
-       strcpy(pci_reserve_param, str);
+       strlcpy(pci_reserve_param, str, sizeof(pci_reserve_param));
        return 1;
 }
 __setup("pci_reserve=", pci_reserve_setup);

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.