summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>1996-10-28 00:36:24 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>1996-10-28 00:36:24 +0000
commit2108268e48704604a61d3039259401d83164d1cf (patch)
tree32ce828578c0a1e449d0569db05ce9460f4aac99 /usr.bin
parent7fc46c112babaa512e07207fb3cf26f280156317 (diff)
Safe $HOME usage.
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/indent/args.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/usr.bin/indent/args.c b/usr.bin/indent/args.c
index b3fd08efe6c..b7abbf77cf5 100644
--- a/usr.bin/indent/args.c
+++ b/usr.bin/indent/args.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: args.c,v 1.2 1996/06/26 05:34:27 deraadt Exp $ */
+/* $OpenBSD: args.c,v 1.3 1996/10/28 00:36:23 millert Exp $ */
/*
* Copyright (c) 1985 Sun Microsystems, Inc.
@@ -37,7 +37,7 @@
#ifndef lint
/*static char sccsid[] = "from: @(#)args.c 5.10 (Berkeley) 2/26/91";*/
-static char rcsid[] = "$OpenBSD: args.c,v 1.2 1996/06/26 05:34:27 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: args.c,v 1.3 1996/10/28 00:36:23 millert Exp $";
#endif /* not lint */
/*
@@ -49,6 +49,7 @@ static char rcsid[] = "$OpenBSD: args.c,v 1.2 1996/06/26 05:34:27 deraadt Exp $"
#include <ctype.h>
#include <stdlib.h>
#include <string.h>
+#include <errno.h>
#include "indent_globs.h"
/* profile types */
@@ -160,6 +161,10 @@ set_profile()
char fname[BUFSIZ];
static char prof[] = ".indent.pro";
+ if (strlen(getenv("HOME")) + sizeof(prof) > sizeof(fname)) {
+ warnx("%s/%s: %s", getenv("HOME"), prof, strerror(ENAMETOOLONG));
+ return;
+ }
sprintf(fname, "%s/%s", getenv("HOME"), prof);
if ((f = fopen(option_source = fname, "r")) != NULL) {
scan_profile(f);