diff options
author | Gilles Chehade <gilles@cvs.openbsd.org> | 2007-09-11 15:47:18 +0000 |
---|---|---|
committer | Gilles Chehade <gilles@cvs.openbsd.org> | 2007-09-11 15:47:18 +0000 |
commit | a8ba60ecf20c221bd24ff666339eb5edcbbbac33 (patch) | |
tree | 650532cc79cb8294b5e7739a5b61676601594950 /usr.bin/tset | |
parent | d0c98e555e46b02b8df61047ae1c820859b23e93 (diff) |
use strcspn to properly overwrite '\n' in fgets returned buffer
ok pyr@, ray@, millert@, moritz@, chl@
Diffstat (limited to 'usr.bin/tset')
-rw-r--r-- | usr.bin/tset/tset.c | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/usr.bin/tset/tset.c b/usr.bin/tset/tset.c index f44bafa1882..8495bff787d 100644 --- a/usr.bin/tset/tset.c +++ b/usr.bin/tset/tset.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tset.c,v 1.29 2007/02/20 01:52:01 ray Exp $ */ +/* $OpenBSD: tset.c,v 1.30 2007/09/11 15:47:17 gilles Exp $ */ /**************************************************************************** * Copyright (c) 1998,1999,2000 Free Software Foundation, Inc. * @@ -204,8 +204,7 @@ askuser(const char *dflt) return (dflt); } - if ((p = strchr(answer, '\n')) != 0) - *p = '\0'; + answer[strcspn(answer, "\n")] = '\0'; if (answer[0]) return (answer); if (dflt != 0) |