Author: blueswirl Date: 2008-11-30 14:44:38 +0100 (Sun, 30 Nov 2008) New Revision: 277
Modified: openbios-devel/arch/amd64/lib.c openbios-devel/arch/ppc/briq/briq.c openbios-devel/arch/ppc/mol/main.c openbios-devel/arch/ppc/mol/mol.c openbios-devel/arch/ppc/pearpc/pearpc.c openbios-devel/arch/ppc/qemu/qemu.c openbios-devel/arch/sparc32/boot.c openbios-devel/arch/sparc32/lib.c openbios-devel/arch/sparc64/boot.c openbios-devel/arch/sparc64/lib.c openbios-devel/arch/sparc64/openbios.c openbios-devel/arch/x86/lib.c openbios-devel/drivers/adb.c openbios-devel/drivers/cuda.c openbios-devel/drivers/esp.c openbios-devel/drivers/ide.c openbios-devel/drivers/obio.c openbios-devel/drivers/pci.c Log: Change uses of sprintf to snprintf
Modified: openbios-devel/arch/amd64/lib.c =================================================================== --- openbios-devel/arch/amd64/lib.c 2008-11-30 13:43:27 UTC (rev 276) +++ openbios-devel/arch/amd64/lib.c 2008-11-30 13:44:38 UTC (rev 277) @@ -19,12 +19,12 @@ */ int printk( const char *fmt, ... ) { - char *p, buf[512]; /* XXX: no buffer overflow protection... */ + char *p, buf[512]; va_list args; int i;
va_start(args, fmt); - i=vsprintf(buf,fmt,args); + i = vsnprintf(buf, sizeof(buf), fmt, args); va_end(args);
for( p=buf; *p; p++ )
Modified: openbios-devel/arch/ppc/briq/briq.c =================================================================== --- openbios-devel/arch/ppc/briq/briq.c 2008-11-30 13:43:27 UTC (rev 276) +++ openbios-devel/arch/ppc/briq/briq.c 2008-11-30 13:44:38 UTC (rev 277) @@ -62,12 +62,12 @@ int printk( const char *fmt, ... ) { - char *p, buf[1024]; /* XXX: no buffer overflow protection... */ + char *p, buf[1024]; va_list args; int i;
va_start(args, fmt); - i=vsprintf(buf,fmt,args); + i = vnsprintf(buf, sizeof(buf), fmt, args); va_end(args);
for( p=buf; *p; p++ ) {
Modified: openbios-devel/arch/ppc/mol/main.c =================================================================== --- openbios-devel/arch/ppc/mol/main.c 2008-11-30 13:43:27 UTC (rev 276) +++ openbios-devel/arch/ppc/mol/main.c 2008-11-30 13:44:38 UTC (rev 277) @@ -300,7 +300,8 @@ continue;
for( j=0; !entry && j<32; j++ ) { - sprintf( spec, "%s/disk@%x:%d", path, i, j ); + snprintf( spec, sizeof(spec), "%s/disk@%x:%d", + path, i, j ); entry = newworld_load( path, spec, (!type || type==2) ); } if( entry ) {
Modified: openbios-devel/arch/ppc/mol/mol.c =================================================================== --- openbios-devel/arch/ppc/mol/mol.c 2008-11-30 13:43:27 UTC (rev 276) +++ openbios-devel/arch/ppc/mol/mol.c 2008-11-30 13:44:38 UTC (rev 277) @@ -57,12 +57,12 @@ int printk( const char *fmt, ... ) { - char *p, buf[1024]; /* XXX: no buffer overflow protection... */ + char *p, buf[1024]; va_list args; int i;
va_start(args, fmt); - i=vsprintf(buf,fmt,args); + i = vnsprintf(buf, sizeof(buf), fmt, args); va_end(args);
for( p=buf; *p; p++ ) {
Modified: openbios-devel/arch/ppc/pearpc/pearpc.c =================================================================== --- openbios-devel/arch/ppc/pearpc/pearpc.c 2008-11-30 13:43:27 UTC (rev 276) +++ openbios-devel/arch/ppc/pearpc/pearpc.c 2008-11-30 13:44:38 UTC (rev 277) @@ -64,12 +64,12 @@ int printk( const char *fmt, ... ) { - char *p, buf[1024]; /* XXX: no buffer overflow protection... */ + char *p, buf[1024]; va_list args; int i;
va_start(args, fmt); - i=vsprintf(buf,fmt,args); + i = vsnprintf(buf, sizeof(buf), fmt, args); va_end(args);
for( p=buf; *p; p++ ) {
Modified: openbios-devel/arch/ppc/qemu/qemu.c =================================================================== --- openbios-devel/arch/ppc/qemu/qemu.c 2008-11-30 13:43:27 UTC (rev 276) +++ openbios-devel/arch/ppc/qemu/qemu.c 2008-11-30 13:44:38 UTC (rev 277) @@ -62,12 +62,12 @@ int printk( const char *fmt, ... ) { - char *p, buf[1024]; /* XXX: no buffer overflow protection... */ + char *p, buf[1024]; va_list args; int i;
va_start(args, fmt); - i=vsprintf(buf,fmt,args); + i = vsnprintf(buf, sizeof(buf), fmt, args); va_end(args);
for( p=buf; *p; p++ ) { @@ -105,7 +105,7 @@ char buf[64];
nvram = (char*)addr + IO_NVRAM_OFFSET; - sprintf(buf, "%s/nvram", path); + snprintf(buf, sizeof(buf), "%s/nvram", path); nvram_init(buf); dnode = find_dev(buf); set_int_property(dnode, "#bytes", IO_NVRAM_SIZE >> 4);
Modified: openbios-devel/arch/sparc32/boot.c =================================================================== --- openbios-devel/arch/sparc32/boot.c 2008-11-30 13:43:27 UTC (rev 276) +++ openbios-devel/arch/sparc32/boot.c 2008-11-30 13:44:38 UTC (rev 277) @@ -107,7 +107,7 @@ if (linux_load(&sys_info, path, param) == LOADER_NOT_SUPPORT) if (aout_load(&sys_info, path, romvec) == LOADER_NOT_SUPPORT) {
- sprintf(altpath, "%s:d", path); + snprintf(altpath, sizeof(altpath), "%s:d", path);
if (elf_load(&sys_info, altpath, param, romvec) == LOADER_NOT_SUPPORT)
Modified: openbios-devel/arch/sparc32/lib.c =================================================================== --- openbios-devel/arch/sparc32/lib.c 2008-11-30 13:43:27 UTC (rev 276) +++ openbios-devel/arch/sparc32/lib.c 2008-11-30 13:44:38 UTC (rev 277) @@ -19,12 +19,12 @@ */ int printk( const char *fmt, ... ) { - char *p, buf[512]; /* XXX: no buffer overflow protection... */ + char *p, buf[512]; va_list args; int i;
va_start(args, fmt); - i=vsprintf(buf,fmt,args); + i = vsnprintf(buf, sizeof(buf), fmt, args); va_end(args);
for( p=buf; *p; p++ )
Modified: openbios-devel/arch/sparc64/boot.c =================================================================== --- openbios-devel/arch/sparc64/boot.c 2008-11-30 13:43:27 UTC (rev 276) +++ openbios-devel/arch/sparc64/boot.c 2008-11-30 13:44:38 UTC (rev 277) @@ -88,7 +88,7 @@ if (aout_load(&sys_info, path) == LOADER_NOT_SUPPORT) if (fcode_load(path) == LOADER_NOT_SUPPORT) {
- sprintf(altpath, "%s:d", path); + snprintf(altpath, sizeof(altpath), "%s:d", path);
if (elf_load(&sys_info, altpath, param) == LOADER_NOT_SUPPORT)
Modified: openbios-devel/arch/sparc64/lib.c =================================================================== --- openbios-devel/arch/sparc64/lib.c 2008-11-30 13:43:27 UTC (rev 276) +++ openbios-devel/arch/sparc64/lib.c 2008-11-30 13:44:38 UTC (rev 277) @@ -19,12 +19,12 @@ */ int printk( const char *fmt, ... ) { - char *p, buf[512]; /* XXX: no buffer overflow protection... */ + char *p, buf[512]; va_list args; int i;
va_start(args, fmt); - i=vsprintf(buf,fmt,args); + i = vsnprintf(buf, sizeof(buf), fmt, args); va_end(args);
for( p=buf; *p; p++ )
Modified: openbios-devel/arch/sparc64/openbios.c =================================================================== --- openbios-devel/arch/sparc64/openbios.c 2008-11-30 13:43:27 UTC (rev 276) +++ openbios-devel/arch/sparc64/openbios.c 2008-11-30 13:44:38 UTC (rev 277) @@ -432,7 +432,7 @@ fword("finish-device");
// MMU node - sprintf(nodebuff, "/%s", cpu->name); + snprintf(nodebuff, sizeof(nodebuff), "/%s", cpu->name); push_str(nodebuff); fword("find-device");
@@ -443,7 +443,7 @@
fword("finish-device");
- sprintf(nodebuff, "/%s/mmu", cpu->name); + snprintf(nodebuff, sizeof(nodebuff), "/%s/mmu", cpu->name);
REGISTER_NODE_METHODS(mmu, nodebuff);
Modified: openbios-devel/arch/x86/lib.c =================================================================== --- openbios-devel/arch/x86/lib.c 2008-11-30 13:43:27 UTC (rev 276) +++ openbios-devel/arch/x86/lib.c 2008-11-30 13:44:38 UTC (rev 277) @@ -19,12 +19,12 @@ */ int printk( const char *fmt, ... ) { - char *p, buf[512]; /* XXX: no buffer overflow protection... */ + char *p, buf[512]; va_list args; int i;
va_start(args, fmt); - i=vsprintf(buf,fmt,args); + i = vsnprintf(buf, sizeof(buf), fmt, args); va_end(args);
for( p=buf; *p; p++ )
Modified: openbios-devel/drivers/adb.c =================================================================== --- openbios-devel/drivers/adb.c 2008-11-30 13:43:27 UTC (rev 276) +++ openbios-devel/drivers/adb.c 2008-11-30 13:44:38 UTC (rev 277) @@ -494,7 +494,7 @@ my_adb_dev = dev; }
- sprintf(buf, "%s/keyboard", path); + snprintf(buf, sizeof(buf), "%s/keyboard", path); REGISTER_NAMED_NODE( keyboard, buf);
ph = find_dev(buf); @@ -551,7 +551,7 @@ phandle_t ph, aliases; adb_dev_t *dev = private;
- sprintf(buf, "%s/mouse", path); + snprintf(buf, sizeof(buf), "%s/mouse", path); REGISTER_NAMED_NODE( mouse, buf);
ph = find_dev(buf);
Modified: openbios-devel/drivers/cuda.c =================================================================== --- openbios-devel/drivers/cuda.c 2008-11-30 13:43:27 UTC (rev 276) +++ openbios-devel/drivers/cuda.c 2008-11-30 13:44:38 UTC (rev 277) @@ -227,7 +227,7 @@ phandle_t ph, aliases; char buf[64];
- sprintf(buf, "%s/rtc", path); + snprintf(buf, sizeof(buf), "%s/rtc", path); REGISTER_NAMED_NODE(rtc, buf);
ph = find_dev(buf); @@ -250,7 +250,7 @@ if (cuda == NULL) return NULL;
- sprintf(buf, "%s/via-cuda", path); + snprintf(buf, sizeof(buf), "%s/via-cuda", path); REGISTER_NAMED_NODE(ob_cuda, buf);
cuda->base = base; @@ -323,7 +323,7 @@ * */ int adb_bus_init (char *path, adb_bus_t *bus) { - char buf[64]; + char buf[64]; uint8_t buffer[ADB_BUF_SIZE]; uint8_t adb_addresses[16] = { 8, 9, 10, 11, 12, 13, 14, -1, -1, -1, -1, -1, -1, -1, 0, }; @@ -332,7 +332,7 @@ int reloc = 0, next_free = 7; int keep;
- sprintf(buf, "%s/adb", path); + snprintf(buf, sizeof(buf), "%s/adb", path); REGISTER_NAMED_NODE( adb, buf); /* Reset the bus */ // ADB_DPRINTF("\n");
Modified: openbios-devel/drivers/esp.c =================================================================== --- openbios-devel/drivers/esp.c 2008-11-30 13:43:27 UTC (rev 276) +++ openbios-devel/drivers/esp.c 2008-11-30 13:44:38 UTC (rev 277) @@ -507,7 +507,8 @@ push_str("reg"); fword("property"); fword("finish-device"); - sprintf(nodebuff, "/iommu/sbus/espdma/esp/sd@%d,0", id); + snprintf(nodebuff, sizeof(nodebuff), "/iommu/sbus/espdma/esp/sd@%d,0", + id); REGISTER_NODE_METHODS(ob_sd, nodebuff); if (esp->sd[id].media == TYPE_ROM) { counter_ptr = &cdcount; @@ -517,11 +518,12 @@ if (*counter_ptr == 0) { add_alias(nodebuff, esp->sd[id].media_str); } - sprintf(aliasbuff, "%s%d", esp->sd[id].media_str, *counter_ptr); + snprintf(aliasbuff, sizeof(aliasbuff), "%s%d", esp->sd[id].media_str, + *counter_ptr); add_alias(nodebuff, aliasbuff); - sprintf(aliasbuff, "sd(0,%d,0)", id); + snprintf(aliasbuff, sizeof(aliasbuff), "sd(0,%d,0)", id); add_alias(nodebuff, aliasbuff); - sprintf(aliasbuff, "sd(0,%d,0)@0,0", id); + snprintf(aliasbuff, sizeof(aliasbuff), "sd(0,%d,0)@0,0", id); add_alias(nodebuff, aliasbuff); (*counter_ptr)++; }
Modified: openbios-devel/drivers/ide.c =================================================================== --- openbios-devel/drivers/ide.c 2008-11-30 13:43:27 UTC (rev 276) +++ openbios-devel/drivers/ide.c 2008-11-30 13:44:38 UTC (rev 277) @@ -1330,7 +1330,7 @@
ob_ide_identify_drives(chan);
- sprintf(nodebuff, nodetemp_chan, i); + snprintf(nodebuff, sizeof(nodebuff), nodetemp_chan, i); REGISTER_NAMED_NODE(ob_ide_ctrl, nodebuff);
printk("ide%d: [io ports 0x%x-0x%x,0x%x]\n", i, chan->io_regs[0], chan->io_regs[0] + 7, chan->io_regs[8]); @@ -1357,7 +1357,8 @@ break; } printk("%s]: %s\n", media, drive->model); - sprintf(nodebuff, nodetemp, i, media); + snprintf(nodebuff, sizeof(nodebuff), nodetemp, i, + media); REGISTER_NAMED_NODE(ob_ide, nodebuff); dnode=find_dev(nodebuff); set_int_property(dnode, "reg", j);
Modified: openbios-devel/drivers/obio.c =================================================================== --- openbios-devel/drivers/obio.c 2008-11-30 13:43:27 UTC (rev 276) +++ openbios-devel/drivers/obio.c 2008-11-30 13:44:38 UTC (rev 277) @@ -275,7 +275,8 @@
fword("finish-device");
- sprintf(nodebuff, "/obio/zs@0,%x", (int)offset & 0xffffffff); + snprintf(nodebuff, sizeof(nodebuff), "/obio/zs@0,%x", + (int)offset & 0xffffffff); if (keyboard) { REGISTER_NODE_METHODS(zs_keyboard, nodebuff); } else {
Modified: openbios-devel/drivers/pci.c =================================================================== --- openbios-devel/drivers/pci.c 2008-11-30 13:43:27 UTC (rev 276) +++ openbios-devel/drivers/pci.c 2008-11-30 13:44:38 UTC (rev 277) @@ -1098,7 +1098,7 @@ phandle_t ph; cell props[2];
- sprintf(buf, "%s/interrupt-controller", config->path); + snprintf(buf, sizeof(buf), "%s/interrupt-controller", config->path); REGISTER_NAMED_NODE(ob_pci_node, buf);
ph = find_dev(buf); @@ -1505,9 +1505,11 @@
dbus=get_cur_dev(); if (pci_dev == NULL || pci_dev->name == NULL) - sprintf(config.path, "%s/pci%x,%x", path, vid, did); + snprintf(config.path, sizeof(config.path), + "%s/pci%x,%x", path, vid, did); else - sprintf(config.path, "%s/%s", path, pci_dev->name); + snprintf(config.path, sizeof(config.path), + "%s/%s", path, pci_dev->name); #ifdef CONFIG_DEBUG_PCI printk("%s - ", config.path); #endif