diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 2003-06-01 17:00:41 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 2003-06-01 17:00:41 +0000 |
commit | 173d01b7c1e9a5d7ba5a6c696a8019061dc41bda (patch) | |
tree | 8c8b7bb08108dca24afcee3bbe301e8ba6f76e81 /sys/arch/sparc64/stand/ofwboot | |
parent | 3e42965de9054a39afc4957c4f099218e709ae51 (diff) |
strcpy/strcat/sprintf removal in all bootblocks. various testing by
various people. outside of some messy things in src/gnu, only one
thing in the main tree now violates this rule: bind
Diffstat (limited to 'sys/arch/sparc64/stand/ofwboot')
-rw-r--r-- | sys/arch/sparc64/stand/ofwboot/boot.c | 35 |
1 files changed, 17 insertions, 18 deletions
diff --git a/sys/arch/sparc64/stand/ofwboot/boot.c b/sys/arch/sparc64/stand/ofwboot/boot.c index 9a2b3378256..0ab68c0218f 100644 --- a/sys/arch/sparc64/stand/ofwboot/boot.c +++ b/sys/arch/sparc64/stand/ofwboot/boot.c @@ -1,4 +1,4 @@ -/* $OpenBSD: boot.c,v 1.7 2003/05/11 20:22:20 mdw Exp $ */ +/* $OpenBSD: boot.c,v 1.8 2003/06/01 17:00:40 deraadt Exp $ */ /* $NetBSD: boot.c,v 1.3 2001/05/31 08:55:19 mrg Exp $ */ /* * Copyright (c) 1997, 1999 Eduardo E. Horvath. All rights reserved. @@ -209,7 +209,7 @@ chain(pentry, args, ssym, esym) #ifdef DEBUG printf("chain: calling OF_chain(%x, %x, %x, %x, %x)\n", - (void *)RELOC, end - (char *)RELOC, entry, args, l); + (void *)RELOC, end - (char *)RELOC, entry, args, l); #endif /* if -D is set then pause in the PROM. */ if (debug > 1) OF_enter(); @@ -248,7 +248,7 @@ loadfile(fd, args) printf("read header: %s\n", strerror(errno)); else printf("read header: short read (only %d of %d)\n", - rval, sizeof(hdr)); + rval, sizeof(hdr)); rval = 1; goto err; } @@ -263,8 +263,7 @@ loadfile(fd, args) if (bcmp(hdr.elf32.e_ident, ELFMAG, SELFMAG) == 0 && hdr.elf32.e_ident[EI_CLASS] == ELFCLASS32) { rval = elf32_exec(fd, &hdr.elf32, &entry, &ssym, &esym); - } else - if (bcmp(hdr.elf64.e_ident, ELFMAG, SELFMAG) == 0 && + } else if (bcmp(hdr.elf64.e_ident, ELFMAG, SELFMAG) == 0 && hdr.elf64.e_ident[EI_CLASS] == ELFCLASS64) { rval = elf64_exec(fd, &hdr.elf64, &entry, &ssym, &esym); } else @@ -476,8 +475,8 @@ elf32_exec(fd, elf, entryp, ssymp, esymp) for (i = 0; i < elf->e_shnum; i++, shp++) { if (shp->sh_type == SHT_NULL) continue; - if (shp->sh_type != SHT_SYMTAB - && shp->sh_type != SHT_STRTAB) { + if (shp->sh_type != SHT_SYMTAB && + shp->sh_type != SHT_STRTAB) { shp->sh_offset = 0; shp->sh_type = SHT_NOBITS; continue; @@ -511,8 +510,8 @@ elf32_exec(fd, elf, entryp, ssymp, esymp) addr += sizeof(Elf32_Ehdr) + (elf->e_shnum * sizeof(Elf32_Shdr)); off = sizeof(Elf32_Ehdr) + (elf->e_shnum * sizeof(Elf32_Shdr)); for (first = 1, i = 0; i < elf->e_shnum; i++, shp++) { - if (shp->sh_type == SHT_SYMTAB - || shp->sh_type == SHT_STRTAB) { + if (shp->sh_type == SHT_SYMTAB || + shp->sh_type == SHT_STRTAB) { if (first) printf("symbols @ 0x%lx ", (u_long)addr); printf("%s%d", first ? "" : "+", shp->sh_size); @@ -552,9 +551,9 @@ main() /* * Get the boot arguments from Openfirmware */ - if ((chosen = OF_finddevice("/chosen")) == -1 - || OF_getprop(chosen, "bootpath", bootdev, sizeof bootdev) < 0 - || OF_getprop(chosen, "bootargs", bootline, sizeof bootline) < 0) { + if ((chosen = OF_finddevice("/chosen")) == -1 || + OF_getprop(chosen, "bootpath", bootdev, sizeof bootdev) < 0 || + OF_getprop(chosen, "bootargs", bootline, sizeof bootline) < 0) { printf("Invalid Openfirmware environment\n"); exit(); } @@ -569,8 +568,8 @@ main() */ bootlp = kernels; - if (parseargs(bootline, &boothowto) == -1 - || (boothowto & RB_ASKNAME)) { + if (parseargs(bootline, &boothowto) == -1 || + (boothowto & RB_ASKNAME)) { bootlp = 0; } else if (*bootline) { just_bootline[0] = bootline; @@ -586,7 +585,7 @@ main() kernels[0] = 0; /* no more iteration */ } else if (cp != bootline) { printf(": trying %s...\n", cp); - strcpy(bootline, cp); + strlcpy(bootline, cp, sizeof bootline); } } if (!bootlp) { @@ -598,8 +597,8 @@ main() bootlp = kernels; continue; } - if (strcmp(bootline, "exit") == 0 - || strcmp(bootline, "halt") == 0) { + if (strcmp(bootline, "exit") == 0 || + strcmp(bootline, "halt") == 0) { _rtt(); } } @@ -611,7 +610,7 @@ main() OF_setprop(chosen, "bootpath", opened_name, strlen(opened_name) + 1); cp = bootline; #else - strcpy(bootline, opened_name); + strlcpy(bootline, opened_name, sizeof bootline); cp = bootline + strlen(bootline); *cp++ = ' '; #endif |