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

[Xen-changelog] [xen-unstable] ia64, ppc: Remove uses of sprintf().



# HG changeset patch
# User Keir Fraser <keir@xxxxxxxxxxxxx>
# Date 1170173656 0
# Node ID bd69e83b65ea5c01e3d93d37b1e873f6204b4b7e
# Parent  300c47bec138704d4753675f293b76ebb702da82
ia64, ppc: Remove uses of sprintf().
Signed-off-by: Christoph Egger <Christoph.Egger@xxxxxxx>
---
 xen/arch/ia64/linux-xen/perfmon.c           |    2 +-
 xen/arch/ia64/linux-xen/setup.c             |    4 ++--
 xen/arch/ia64/linux-xen/sn/kernel/io_init.c |    4 ++--
 xen/arch/ia64/linux-xen/unaligned.c         |    2 +-
 xen/arch/ia64/xen/domain.c                  |    2 +-
 xen/arch/ia64/xen/gdbstub.c                 |   14 +++++++-------
 xen/arch/ia64/xen/xensetup.c                |    4 ++--
 xen/arch/powerpc/domain_build.c             |    2 +-
 8 files changed, 17 insertions(+), 17 deletions(-)

diff -r 300c47bec138 -r bd69e83b65ea xen/arch/ia64/linux-xen/perfmon.c
--- a/xen/arch/ia64/linux-xen/perfmon.c Tue Jan 30 16:09:16 2007 +0000
+++ b/xen/arch/ia64/linux-xen/perfmon.c Tue Jan 30 16:14:16 2007 +0000
@@ -2305,7 +2305,7 @@ pfm_alloc_fd(struct file **cfile)
        inode->i_uid  = current->fsuid;
        inode->i_gid  = current->fsgid;
 
-       sprintf(name, "[%lu]", inode->i_ino);
+       snprintf(name, sizeof(name), "[%lu]", inode->i_ino);
        this.name = name;
        this.len  = strlen(name);
        this.hash = inode->i_ino;
diff -r 300c47bec138 -r bd69e83b65ea xen/arch/ia64/linux-xen/setup.c
--- a/xen/arch/ia64/linux-xen/setup.c   Tue Jan 30 16:09:16 2007 +0000
+++ b/xen/arch/ia64/linux-xen/setup.c   Tue Jan 30 16:14:16 2007 +0000
@@ -550,7 +550,7 @@ show_cpuinfo (struct seq_file *m, void *
        switch (c->family) {
              case 0x07:        memcpy(family, "Itanium", 8); break;
              case 0x1f:        memcpy(family, "Itanium 2", 10); break;
-             default:          sprintf(family, "%u", c->family); break;
+             default:          snprintf(family, sizeof(family), "%u", 
c->family); break;
        }
 
        /* build the feature string: */
@@ -572,7 +572,7 @@ show_cpuinfo (struct seq_file *m, void *
                /* print unknown features as a hex value: */
                if (sep)
                        *cp++ = sep;
-               sprintf(cp, " 0x%lx", mask);
+               snprintf(cp, sizeof(features) - (cp - features), " 0x%lx", 
mask);
        }
 
        seq_printf(m,
diff -r 300c47bec138 -r bd69e83b65ea xen/arch/ia64/linux-xen/sn/kernel/io_init.c
--- a/xen/arch/ia64/linux-xen/sn/kernel/io_init.c       Tue Jan 30 16:09:16 
2007 +0000
+++ b/xen/arch/ia64/linux-xen/sn/kernel/io_init.c       Tue Jan 30 16:14:16 
2007 +0000
@@ -754,7 +754,7 @@ void sn_generate_path(struct pci_bus *pc
        geoid = cnodeid_get_geoid(cnode);
        moduleid = geo_module(geoid);
 
-       sprintf(address, "module_%c%c%c%c%.2d",
+       snprintf(address, 15, "module_%c%c%c%c%.2d",
                '0'+RACK_GET_CLASS(MODULE_GET_RACK(moduleid)),
                '0'+RACK_GET_GROUP(MODULE_GET_RACK(moduleid)),
                '0'+RACK_GET_NUM(MODULE_GET_RACK(moduleid)),
@@ -764,7 +764,7 @@ void sn_generate_path(struct pci_bus *pc
        bricktype = MODULE_GET_BTYPE(moduleid);
        if ((bricktype == L1_BRICKTYPE_191010) ||
            (bricktype == L1_BRICKTYPE_1932))
-                       sprintf(address, "%s^%d", address, geo_slot(geoid));
+                       snprintf(address, 15+8, "%s^%d", address, 
geo_slot(geoid));
 }
 #endif
 
diff -r 300c47bec138 -r bd69e83b65ea xen/arch/ia64/linux-xen/unaligned.c
--- a/xen/arch/ia64/linux-xen/unaligned.c       Tue Jan 30 16:09:16 2007 +0000
+++ b/xen/arch/ia64/linux-xen/unaligned.c       Tue Jan 30 16:14:16 2007 +0000
@@ -1792,7 +1792,7 @@ printk("ia64_handle_unaligned: called, n
                        char buf[200];  /* comm[] is at most 16 bytes... */
                        size_t len;
 
-                       len = sprintf(buf, "%s(%d): unaligned access to 
0x%016lx, "
+                       len = snprintf(buf, sizeof(buf), "%s(%d): unaligned 
access to 0x%016lx, "
                                      "ip=0x%016lx\n\r", current->comm, 
current->pid,
                                      ifa, regs->cr_iip + ipsr->ri);
                        /*
diff -r 300c47bec138 -r bd69e83b65ea xen/arch/ia64/xen/domain.c
--- a/xen/arch/ia64/xen/domain.c        Tue Jan 30 16:09:16 2007 +0000
+++ b/xen/arch/ia64/xen/domain.c        Tue Jan 30 16:14:16 2007 +0000
@@ -1124,7 +1124,7 @@ int construct_dom0(struct domain *d,
                panic("can't allocate start info page");
        si = page_to_virt(start_info_page);
        memset(si, 0, PAGE_SIZE);
-       sprintf(si->magic, "xen-%i.%i-ia64",
+       snprintf(si->magic, sizeof(si->magic), "xen-%i.%i-ia64",
                xen_major_version(), xen_minor_version());
        si->nr_pages     = max_pages;
        si->flags = SIF_INITDOMAIN|SIF_PRIVILEGED;
diff -r 300c47bec138 -r bd69e83b65ea xen/arch/ia64/xen/gdbstub.c
--- a/xen/arch/ia64/xen/gdbstub.c       Tue Jan 30 16:09:16 2007 +0000
+++ b/xen/arch/ia64/xen/gdbstub.c       Tue Jan 30 16:14:16 2007 +0000
@@ -289,13 +289,13 @@ gdb_arch_read_reg(unsigned long regnum, 
        }
 
        dbg_printk("Register read regnum = 0x%lx, val = 0x%lx\n", regnum, reg); 
-       sprintf(buf, "%.08lx", swab64(reg));
+       snprintf(buf, sizeof(buf), "%.08lx", swab64(reg));
 out:
        return gdb_send_reply(buf, ctx);
 
 out_err:
        dbg_printk("Register read unsupported regnum = 0x%lx\n", regnum);
-       sprintf(buf, "%s", "x");
+       safe_strcpy(buf, "x");
        goto out;
 }
 #else
@@ -756,19 +756,19 @@ gdb_arch_read_reg(unsigned long regnum, 
        if (arg.error > 0) {
                // notify gdb that this register is not supported.
                // see fetch_register_using_p() in gdb/remote.c.
-               sprintf(buf, "%s", "x");
+               safe_strcpy(buf, "x");
        } else if (IA64_FR0_REGNUM <= regnum && regnum <= IA64_FR0_REGNUM + 
127) {
-               sprintf(buf, "%.016lx", swab64(freg.u.bits[0]));
-               sprintf(buf + 16, "%.016lx", swab64(freg.u.bits[1]));
+               snprintf(buf, sizeof(buf), "%.016lx", swab64(freg.u.bits[0]));
+               snprintf(buf + 16, sizeof(buf) - 16, "%.016lx", 
swab64(freg.u.bits[1]));
        } else {
-               sprintf(buf, "%.016lx", swab64(reg));
+               snprintf(buf, sizeof(buf), "%.016lx", swab64(reg));
        }
 out:
        return gdb_send_reply(buf, ctx);
 
 out_err:
        dbg_printk("Register read unsupported regnum = 0x%lx\n", regnum);
-       sprintf(buf, "%s", "E0");
+       safe_strcpy(buf, "E0");
        goto out;
 }
 #endif
diff -r 300c47bec138 -r bd69e83b65ea xen/arch/ia64/xen/xensetup.c
--- a/xen/arch/ia64/xen/xensetup.c      Tue Jan 30 16:09:16 2007 +0000
+++ b/xen/arch/ia64/xen/xensetup.c      Tue Jan 30 16:14:16 2007 +0000
@@ -551,10 +551,10 @@ void arch_get_xen_caps(xen_capabilities_
     int major = xen_major_version();
     int minor = xen_minor_version();
 
-    p += sprintf(p,"xen-%d.%d-ia64 ", major, minor);
+    p += snprintf(p,sizeof(info), "xen-%d.%d-ia64 ", major, minor);
 
     if (vmx_enabled)
-        p += sprintf(p,"hvm-%d.%d-ia64 ", major, minor);
+        p += snprintf(p,sizeof(info) - (p - info),"hvm-%d.%d-ia64 ", major, 
minor);
 
     *(p-1) = 0;
 
diff -r 300c47bec138 -r bd69e83b65ea xen/arch/powerpc/domain_build.c
--- a/xen/arch/powerpc/domain_build.c   Tue Jan 30 16:09:16 2007 +0000
+++ b/xen/arch/powerpc/domain_build.c   Tue Jan 30 16:14:16 2007 +0000
@@ -185,7 +185,7 @@ int construct_dom0(struct domain *d,
     si = (start_info_t *)(rma_addr(&d->arch, RMA_START_INFO) + rma);
     printk("xen_start_info: %p\n", si);
 
-    sprintf(si->magic, "xen-%i.%i-powerpc%d%s",
+    snprintf(si->magic, sizeof(si->magic), "xen-%i.%i-powerpc%d%s",
             xen_major_version(), xen_minor_version(), BITS_PER_LONG, "HV");
     si->flags = SIF_PRIVILEGED | SIF_INITDOMAIN;
 

_______________________________________________
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®.