From 3fdd26c169b3cd992ae051f07bcbe76bc5a6bc85 Mon Sep 17 00:00:00 2001 From: chl <> Date: Sun, 9 Sep 2007 23:25:12 +0000 Subject: use strcspn to properly overwrite '\n' in fgets returned buffer ok moritz@ gilles@ --- src/regress/lib/libc/regex/main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/regress/lib/libc/regex/main.c') diff --git a/src/regress/lib/libc/regex/main.c b/src/regress/lib/libc/regex/main.c index fd092905fa..15e0bc8c1f 100644 --- a/src/regress/lib/libc/regex/main.c +++ b/src/regress/lib/libc/regex/main.c @@ -1,4 +1,4 @@ -/* $OpenBSD: main.c,v 1.5 2004/02/28 08:06:46 deraadt Exp $ */ +/* $OpenBSD: main.c,v 1.6 2007/09/09 23:25:12 chl Exp $ */ /* $NetBSD: main.c,v 1.2 1995/04/20 22:39:51 cgd Exp $ */ #include @@ -147,7 +147,7 @@ FILE *in; line++; if (inbuf[0] == '#' || inbuf[0] == '\n') continue; /* NOTE CONTINUE */ - inbuf[strlen(inbuf)-1] = '\0'; /* get rid of stupid \n */ + inbuf[strcspn(inbuf, "\n")] = '\0'; /* get rid of stupid \n */ if (debug) fprintf(stdout, "%d:\n", line); nf = split(inbuf, f, MAXF, "\t\t"); -- cgit v1.2.3-55-g6feb