diff options
author | Todd C. Miller <millert@cvs.openbsd.org> | 2006-10-18 23:30:44 +0000 |
---|---|---|
committer | Todd C. Miller <millert@cvs.openbsd.org> | 2006-10-18 23:30:44 +0000 |
commit | 2c4c0aabf47d572bb04356aaff82f45a40fceb9c (patch) | |
tree | 1e68a6a3383c3dcfe23035a43bf239e138b73b60 /usr.bin/sort/sort.c | |
parent | e96ebc5a5c186f887f6bf9610f9a5399dbac1f2f (diff) |
Remove useless code that can cause a SEGV if a buffer is realloc()ed.
Allocate buffers early and in one place instead of two.
Fixes PR 5252; OK deraadt
Diffstat (limited to 'usr.bin/sort/sort.c')
-rw-r--r-- | usr.bin/sort/sort.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/usr.bin/sort/sort.c b/usr.bin/sort/sort.c index dd6fb285132..430f3854d2e 100644 --- a/usr.bin/sort/sort.c +++ b/usr.bin/sort/sort.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sort.c,v 1.28 2005/10/04 15:10:27 jmc Exp $ */ +/* $OpenBSD: sort.c,v 1.29 2006/10/18 23:30:43 millert Exp $ */ /*- * Copyright (c) 1993 @@ -42,7 +42,7 @@ static char copyright[] = #if 0 static char sccsid[] = "@(#)sort.c 8.1 (Berkeley) 6/6/93"; #else -static char rcsid[] = "$OpenBSD: sort.c,v 1.28 2005/10/04 15:10:27 jmc Exp $"; +static char rcsid[] = "$OpenBSD: sort.c,v 1.29 2006/10/18 23:30:43 millert Exp $"; #endif #endif /* not lint */ @@ -254,6 +254,13 @@ main(int argc, char *argv[]) else get = makekey; + if ((buffer = malloc(bufsize)) == NULL) + err(2, NULL); + if (!SINGL_FLD) { + if ((linebuf = malloc(linebuf_size)) == NULL) + err(2, NULL); + } + if (cflag) { order(filelist, get, fldtab); /* NOT REACHED */ |