summaryrefslogtreecommitdiffstats
path: root/usr.bin/sort/sort.c
diff options
context:
space:
mode:
authormillert <millert@openbsd.org>2015-04-01 20:28:04 +0000
committermillert <millert@openbsd.org>2015-04-01 20:28:04 +0000
commitf46abe7be949acfdbbca68a44b28a73caae12537 (patch)
tree6236e73a9665e1c69817722ef41af0c3b75f5540 /usr.bin/sort/sort.c
parentUse memcpy() not strncpy() when dynamically allocating and copying (diff)
downloadwireguard-openbsd-f46abe7be949acfdbbca68a44b28a73caae12537.tar.xz
wireguard-openbsd-f46abe7be949acfdbbca68a44b28a73caae12537.zip
If strtoul() fails to parse the argument to -k, just pass the
error back to the caller instead of calling err() directly. The user gets a more useful error message this way.
Diffstat (limited to 'usr.bin/sort/sort.c')
-rw-r--r--usr.bin/sort/sort.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/usr.bin/sort/sort.c b/usr.bin/sort/sort.c
index c6d89fbc586..88f99c9768b 100644
--- a/usr.bin/sort/sort.c
+++ b/usr.bin/sort/sort.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sort.c,v 1.57 2015/04/01 20:24:12 millert Exp $ */
+/* $OpenBSD: sort.c,v 1.58 2015/04/01 20:28:04 millert Exp $ */
/*-
* Copyright (C) 2009 Gabor Kovesdan <gabor@FreeBSD.org>
@@ -561,18 +561,18 @@ parse_pos(const char *s, struct key_specs *ks, bool *mef_flags, bool second)
if (second) {
errno = 0;
- ks->f2 = (size_t) strtoul(f, NULL, 10);
+ ks->f2 = (size_t)strtoul(f, NULL, 10);
if (errno != 0)
- err(2, "-k");
+ goto end;
if (ks->f2 == 0) {
warn("0 field in key specs");
goto end;
}
} else {
errno = 0;
- ks->f1 = (size_t) strtoul(f, NULL, 10);
+ ks->f1 = (size_t)strtoul(f, NULL, 10);
if (errno != 0)
- err(2, "-k");
+ goto end;
if (ks->f1 == 0) {
warn("0 field in key specs");
goto end;
@@ -588,14 +588,14 @@ parse_pos(const char *s, struct key_specs *ks, bool *mef_flags, bool second)
if (second) {
errno = 0;
- ks->c2 = (size_t) strtoul(c, NULL, 10);
+ ks->c2 = (size_t)strtoul(c, NULL, 10);
if (errno != 0)
- err(2, "-k");
+ goto end;
} else {
errno = 0;
- ks->c1 = (size_t) strtoul(c, NULL, 10);
+ ks->c1 = (size_t)strtoul(c, NULL, 10);
if (errno != 0)
- err(2, "-k");
+ goto end;
if (ks->c1 == 0) {
warn("0 column in key specs");
goto end;