diff options
author | Alan Coopersmith <alan.coopersmith@oracle.com> | 2011-10-29 11:08:17 -0700 |
---|---|---|
committer | Alan Coopersmith <alan.coopersmith@oracle.com> | 2011-11-23 12:15:06 -0800 |
commit | 05d8a7f7a785eff3292f0f0537bb3902930f1b5c (patch) | |
tree | 43dc322a988c1fab65622c2aea31c2b818ce20c8 /hw/xfree86/os-support | |
parent | b967bf2af264726042e2f6ffb9ca7d234f34b56b (diff) |
Convert a bunch of sprintf to snprintf calls
This batch is the straightforward set - others are more complex and
need more analysis to determine right size to pass.
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Jeremy Huddleston <jeremyhu@apple.com>
Diffstat (limited to 'hw/xfree86/os-support')
-rw-r--r-- | hw/xfree86/os-support/bsd/bsd_init.c | 10 | ||||
-rw-r--r-- | hw/xfree86/os-support/bus/Sbus.c | 12 | ||||
-rw-r--r-- | hw/xfree86/os-support/linux/lnx_init.c | 2 |
3 files changed, 12 insertions, 12 deletions
diff --git a/hw/xfree86/os-support/bsd/bsd_init.c b/hw/xfree86/os-support/bsd/bsd_init.c index b58d6a790..7079d62b4 100644 --- a/hw/xfree86/os-support/bsd/bsd_init.c +++ b/hw/xfree86/os-support/bsd/bsd_init.c @@ -446,7 +446,7 @@ xf86OpenSyscons() } close(fd); - sprintf(vtname, "/dev/ttyv%01x", xf86Info.vtno - 1); + snprintf(vtname, sizeof(vtname), "/dev/ttyv%01x", xf86Info.vtno - 1); if ((fd = open(vtname, SYSCONS_CONSOLE_MODE, 0)) < 0) { FatalError("xf86OpenSyscons: Cannot open %s (%s)", @@ -550,13 +550,13 @@ xf86OpenPcvt() } close(fd); - sprintf(vtname, "%s%01x", vtprefix, xf86Info.vtno - 1); + snprintf(vtname, sizeof(vtname), "%s%01x", vtprefix, xf86Info.vtno - 1); if ((fd = open(vtname, PCVT_CONSOLE_MODE, 0)) < 0) { ErrorF("xf86OpenPcvt: Cannot open %s (%s)", vtname, strerror(errno)); xf86Info.vtno = initialVT; - sprintf(vtname, "%s%01x", vtprefix, xf86Info.vtno - 1); + snprintf(vtname, sizeof(vtname), "%s%01x", vtprefix, xf86Info.vtno - 1); if ((fd = open(vtname, PCVT_CONSOLE_MODE, 0)) < 0) { FatalError("xf86OpenPcvt: Cannot open %s (%s)", vtname, strerror(errno)); @@ -602,9 +602,9 @@ xf86OpenWScons() /* XXX Is this ok? */ for (i = 0; i < 8; i++) { #if defined(__NetBSD__) - sprintf(ttyname, "/dev/ttyE%d", i); + snprintf(ttyname, sizeof(ttyname), "/dev/ttyE%d", i); #elif defined(__OpenBSD__) - sprintf(ttyname, "/dev/ttyC%x", i); + snprintf(ttyname, sizeof(ttyname), "/dev/ttyC%x", i); #endif if ((fd = open(ttyname, 2)) != -1) break; diff --git a/hw/xfree86/os-support/bus/Sbus.c b/hw/xfree86/os-support/bus/Sbus.c index 7829d803f..c02d2cd55 100644 --- a/hw/xfree86/os-support/bus/Sbus.c +++ b/hw/xfree86/os-support/bus/Sbus.c @@ -446,14 +446,14 @@ promGetReg(int type) if (prop && len >= 4) { unsigned int *reg = (unsigned int *)prop; if (!promP1275 || (type == PROM_NODE_SBUS) || (type == PROM_NODE_EBUS)) - sprintf (regstr, "@%x,%x", reg[0], reg[1]); + snprintf (regstr, sizeof(regstr), "@%x,%x", reg[0], reg[1]); else if (type == PROM_NODE_PCI) { if ((reg[0] >> 8) & 7) - sprintf (regstr, "@%x,%x", (reg[0] >> 11) & 0x1f, (reg[0] >> 8) & 7); + snprintf (regstr, sizeof(regstr), "@%x,%x", (reg[0] >> 11) & 0x1f, (reg[0] >> 8) & 7); else - sprintf (regstr, "@%x", (reg[0] >> 11) & 0x1f); + snprintf (regstr, sizeof(regstr), "@%x", (reg[0] >> 11) & 0x1f); } else if (len == 4) - sprintf (regstr, "@%x", reg[0]); + snprintf (regstr, sizeof(regstr), "@%x", reg[0]); else { unsigned int regs[2]; @@ -465,9 +465,9 @@ promGetReg(int type) prop = promGetProperty("upa-portid", &len); if (prop && len == 4) { reg = (unsigned int *)prop; - sprintf (regstr, "@%x,%x", reg[0], regs[1]); + snprintf (regstr, sizeof(regstr), "@%x,%x", reg[0], regs[1]); } else - sprintf (regstr, "@%x,%x", regs[0] >> 4, regs[1]); + snprintf (regstr, sizeof(regstr), "@%x,%x", regs[0] >> 4, regs[1]); } } return regstr; diff --git a/hw/xfree86/os-support/linux/lnx_init.c b/hw/xfree86/os-support/linux/lnx_init.c index f18271f38..5f3e3a9fb 100644 --- a/hw/xfree86/os-support/linux/lnx_init.c +++ b/hw/xfree86/os-support/linux/lnx_init.c @@ -146,7 +146,7 @@ xf86OpenConsole(void) i=0; while (vcs[i] != NULL) { - sprintf(vtname, vcs[i], xf86Info.vtno); /* /dev/tty1-64 */ + snprintf(vtname, sizeof(vtname), vcs[i], xf86Info.vtno); /* /dev/tty1-64 */ if ((xf86Info.consoleFd = open(vtname, O_RDWR|O_NDELAY, 0)) >= 0) break; i++; |