diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 2000-09-15 07:13:52 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 2000-09-15 07:13:52 +0000 |
commit | 42a3e69c05af72afbc1d37574fba7729b828289b (patch) | |
tree | becf08be7a11e201542de4de93b8cd0f8650f9e1 /gnu | |
parent | b74ef7bac5077f29fc1c12e8b5ccaf0e2f1f8fdc (diff) |
check return value for setenv(3) for failure, and deal appropriately
Diffstat (limited to 'gnu')
-rw-r--r-- | gnu/libexec/ld.so/ldd/ldd.c | 9 | ||||
-rw-r--r-- | gnu/usr.bin/ld/ldd/ldd.c | 14 |
2 files changed, 16 insertions, 7 deletions
diff --git a/gnu/libexec/ld.so/ldd/ldd.c b/gnu/libexec/ld.so/ldd/ldd.c index 6cb11b2b6a3..78a37bc75c1 100644 --- a/gnu/libexec/ld.so/ldd/ldd.c +++ b/gnu/libexec/ld.so/ldd/ldd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ldd.c,v 1.2 1998/01/28 10:52:45 pefo Exp $ */ +/* $OpenBSD: ldd.c,v 1.3 2000/09/15 07:13:44 deraadt Exp $ */ /* * Copyright (c) 1996 Per Fogelstrom @@ -77,7 +77,12 @@ main(argc, argv) else if(lflag && readsoneeded(f, 1)) { fclose(f); - setenv("LD_TRACE_LOADED_OBJECTS", "1", 1); + if (setenv("LD_TRACE_LOADED_OBJECTS", "1", 1) == -1) { + fprintf(stderr, + "%s: can't setenv LD_TRACE_LOADED_OBJECTS\n", + argv[0]); + exit(2); + } execl(argv[i], NULL); } exit(0); diff --git a/gnu/usr.bin/ld/ldd/ldd.c b/gnu/usr.bin/ld/ldd/ldd.c index c61de2a388f..cbac7194497 100644 --- a/gnu/usr.bin/ld/ldd/ldd.c +++ b/gnu/usr.bin/ld/ldd/ldd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ldd.c,v 1.5 1999/05/21 01:20:45 espie Exp $ */ +/* $OpenBSD: ldd.c,v 1.6 2000/09/15 07:13:44 deraadt Exp $ */ /* $NetBSD: ldd.c,v 1.12 1995/10/09 00:14:41 pk Exp $ */ /* * Copyright (c) 1993 Paul Kranenburg @@ -87,11 +87,14 @@ char *argv[]; } /* ld.so magic */ - setenv("LD_TRACE_LOADED_OBJECTS", "", 1); + if (setenv("LD_TRACE_LOADED_OBJECTS", "", 1) == -1) + err(1, "cannot setenv LD_TRACE_LOADED_OBJECTS"); if (fmt1) - setenv("LD_TRACE_LOADED_OBJECTS_FMT1", fmt1, 1); + if (setenv("LD_TRACE_LOADED_OBJECTS_FMT1", fmt1, 1) == -1) + err(1, "cannot setenv LD_TRACE_LOADED_OBJECTS_FMT1"); if (fmt2) - setenv("LD_TRACE_LOADED_OBJECTS_FMT2", fmt2, 1); + if (setenv("LD_TRACE_LOADED_OBJECTS_FMT2", fmt2, 1) == -1) + err(1, "cannot setenv LD_TRACE_LOADED_OBJECTS_FMT2"); rval = 0; while (argc--) { @@ -132,7 +135,8 @@ char *argv[]; } (void)close(fd); - setenv("LD_TRACE_LOADED_OBJECTS_PROGNAME", *argv, 1); + if (setenv("LD_TRACE_LOADED_OBJECTS_PROGNAME", *argv, 1) == -1) + err(1, "cannot setenv LD_TRACE_LOADED_OBJECTS_PROGNAME"); if (fmt1 == NULL && fmt2 == NULL) /* Default formats */ printf("%s:\n", *argv); |