diff options
| author | Joerg Wunsch <joerg@FreeBSD.org> | 1997-02-09 20:38:03 +0000 |
|---|---|---|
| committer | Joerg Wunsch <joerg@FreeBSD.org> | 1997-02-09 20:38:03 +0000 |
| commit | c51e3ae17c7018b1a7ada22d10ab7ec08ceba661 (patch) | |
| tree | 6812b504124904956e06a0712622e1613e9f8a96 /usr.bin/brandelf | |
| parent | f732ee7ed240dd2e69da70391e70deb4c0792bbb (diff) | |
Notes
Diffstat (limited to 'usr.bin/brandelf')
| -rw-r--r-- | usr.bin/brandelf/Makefile | 2 | ||||
| -rw-r--r-- | usr.bin/brandelf/brandelf.c | 23 |
2 files changed, 16 insertions, 9 deletions
diff --git a/usr.bin/brandelf/Makefile b/usr.bin/brandelf/Makefile index 8fbff966fdb1..3561ec00cf75 100644 --- a/usr.bin/brandelf/Makefile +++ b/usr.bin/brandelf/Makefile @@ -1,5 +1,3 @@ PROG= brandelf -NOMAN= brandelf.1 - .include <bsd.prog.mk> diff --git a/usr.bin/brandelf/brandelf.c b/usr.bin/brandelf/brandelf.c index b89143733e59..b170c3ea4c27 100644 --- a/usr.bin/brandelf/brandelf.c +++ b/usr.bin/brandelf/brandelf.c @@ -25,22 +25,24 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * $Id$ + * $Id: brandelf.c,v 1.1 1996/10/16 18:16:22 sos Exp $ */ #include <stdlib.h> #include <stdio.h> +#include <string.h> +#include <unistd.h> #include <fcntl.h> #include <sys/imgact_elf.h> -int usage(); +int usage(void); +int main(int argc, char **argv) { - extern char *optarg; - extern int optind; - char type[10] = "FreeBSD"; + const char *type = "FreeBSD"; + int retval = 0; int ch, change = 0, verbose = 0; while ((ch = getopt(argc, argv, "t:v")) != EOF) @@ -50,7 +52,7 @@ main(int argc, char **argv) break; case 't': change = 1; - strcpy(type, optarg); + type = optarg; break; default: usage(); @@ -68,17 +70,20 @@ main(int argc, char **argv) if ((fd = open(argv[0], O_RDWR, 0)) < 0) { fprintf(stderr, "No such file %s.\n", argv[0]); + retval = 1; goto fail; } if (read(fd, buffer, EI_NINDENT) < EI_NINDENT) { fprintf(stderr, "File '%s' too short.\n", argv[0]); + retval = 1; goto fail; } if (buffer[0] != ELFMAG0 || buffer[1] != ELFMAG1 || buffer[2] != ELFMAG2 || buffer[3] != ELFMAG3) { fprintf(stderr, "File '%s' is not ELF format.\n", argv[0]); + retval = 1; goto fail; } if (!change) { @@ -97,6 +102,7 @@ main(int argc, char **argv) lseek(fd, 0, SEEK_SET); if (write(fd, buffer, EI_NINDENT) != EI_NINDENT) { fprintf(stderr, "Error writing %s\n", argv[0]); + retval = 1; goto fail; } } @@ -104,10 +110,13 @@ fail: argc--; argv++; } + + return retval; } int -usage() +usage(void) { fprintf(stderr, "Usage: brandelf [-t string] file ...\n"); + exit(1); } |
