diff options
author | 2014-12-13 10:31:07 +0000 | |
---|---|---|
committer | 2014-12-13 10:31:07 +0000 | |
commit | 71847ebdc6411ce9154e1448ea3120fd6a57b2a0 (patch) | |
tree | 684ef80b5eab3290107c724e2983e5f59d1cd4d2 /usr.bin/patch/patch.c | |
parent | macro cleanup; from Kaspars Bankovskis, tweaked a bit (diff) | |
download | wireguard-openbsd-71847ebdc6411ce9154e1448ea3120fd6a57b2a0.tar.xz wireguard-openbsd-71847ebdc6411ce9154e1448ea3120fd6a57b2a0.zip |
The function savestr allows NULL return values during Plan A patching so in
case of out of memory conditions, Plan B can step in. In many cases, NULL
value is not properly handled, so use xstrdup here (it's outside Plan A/B
patching, which means that even Plan B relies on successful operations).
Diffstat (limited to 'usr.bin/patch/patch.c')
-rw-r--r-- | usr.bin/patch/patch.c | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/usr.bin/patch/patch.c b/usr.bin/patch/patch.c index ea7ba2ee275..d53bda30193 100644 --- a/usr.bin/patch/patch.c +++ b/usr.bin/patch/patch.c @@ -1,4 +1,4 @@ -/* $OpenBSD: patch.c,v 1.53 2014/12/08 21:59:36 deraadt Exp $ */ +/* $OpenBSD: patch.c,v 1.54 2014/12/13 10:31:07 tobias Exp $ */ /* * patch - a program to apply diffs to original files @@ -213,7 +213,7 @@ main(int argc, char *argv[]) warn_on_invalid_line = true; if (outname == NULL) - outname = savestr(filearg[0]); + outname = xstrdup(filearg[0]); /* for ed script just up and do it and exit */ if (diff_type == ED_DIFF) { @@ -491,10 +491,10 @@ get_some_switches(void) /* FALLTHROUGH */ case 'z': /* must directly follow 'b' case for backwards compat */ - simple_backup_suffix = savestr(optarg); + simple_backup_suffix = xstrdup(optarg); break; case 'B': - origprae = savestr(optarg); + origprae = xstrdup(optarg); break; case 'c': diff_type = CONTEXT_DIFF; @@ -532,7 +532,7 @@ get_some_switches(void) case 'i': if (++filec == MAXFILEC) fatal("too many file arguments\n"); - filearg[filec] = savestr(optarg); + filearg[filec] = xstrdup(optarg); break; case 'l': canonicalize = true; @@ -544,7 +544,7 @@ get_some_switches(void) noreverse = true; break; case 'o': - outname = savestr(optarg); + outname = xstrdup(optarg); break; case 'p': strippath = atoi(optarg); @@ -588,12 +588,12 @@ get_some_switches(void) Argv += optind; if (Argc > 0) { - filearg[0] = savestr(*Argv++); + filearg[0] = xstrdup(*Argv++); Argc--; while (Argc > 0) { if (++filec == MAXFILEC) fatal("too many file arguments\n"); - filearg[filec] = savestr(*Argv++); + filearg[filec] = xstrdup(*Argv++); Argc--; } } |