summaryrefslogtreecommitdiffstats
path: root/usr.bin/sort/sort.c
diff options
context:
space:
mode:
authormillert <millert@openbsd.org>2017-01-04 15:30:58 +0000
committermillert <millert@openbsd.org>2017-01-04 15:30:58 +0000
commitc39a2ed9eba9573a8dfdcb22ddd0d1cb2ee3cecb (patch)
tree3e9cc0b686312f82ed61a226f67ce85ec0e93ccd /usr.bin/sort/sort.c
parentRemove unnecessary casts of 'a' to char * since 'a' is already char *. (diff)
downloadwireguard-openbsd-c39a2ed9eba9573a8dfdcb22ddd0d1cb2ee3cecb.tar.xz
wireguard-openbsd-c39a2ed9eba9573a8dfdcb22ddd0d1cb2ee3cecb.zip
Fix a crash when "sort -m" is given no files. From Julien Ramseier.
Diffstat (limited to 'usr.bin/sort/sort.c')
-rw-r--r--usr.bin/sort/sort.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/usr.bin/sort/sort.c b/usr.bin/sort/sort.c
index d986cb23365..617a6c37dc4 100644
--- a/usr.bin/sort/sort.c
+++ b/usr.bin/sort/sort.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sort.c,v 1.86 2016/07/14 08:31:18 semarie Exp $ */
+/* $OpenBSD: sort.c,v 1.87 2017/01/04 15:30:58 millert Exp $ */
/*-
* Copyright (C) 2009 Gabor Kovesdan <gabor@FreeBSD.org>
@@ -1224,7 +1224,10 @@ main(int argc, char *argv[])
struct file_list fl;
file_list_init(&fl, false);
- file_list_populate(&fl, argc, argv, true);
+ if (argc < 1)
+ file_list_add(&fl, "-", true);
+ else
+ file_list_populate(&fl, argc, argv, true);
merge_files(&fl, outfile);
file_list_clean(&fl);
}