mirror of
https://github.com/openbsd/src.git
synced 2025-01-10 06:47:55 -08:00
use strcspn to properly overwrite '\n' in fgets returned buffer
ok pyr@, ray@, millert@, moritz@, chl@
This commit is contained in:
parent
712678dfc6
commit
4fd6ed3243
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: diffreg.c,v 1.69 2007/06/09 05:16:21 ray Exp $ */
|
||||
/* $OpenBSD: diffreg.c,v 1.70 2007/09/11 15:47:17 gilles Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (C) Caldera International Inc. 2001-2002.
|
||||
@ -65,7 +65,7 @@
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
static const char rcsid[] = "$OpenBSD: diffreg.c,v 1.69 2007/06/09 05:16:21 ray Exp $";
|
||||
static const char rcsid[] = "$OpenBSD: diffreg.c,v 1.70 2007/09/11 15:47:17 gilles Exp $";
|
||||
#endif /* not lint */
|
||||
|
||||
#include <sys/param.h>
|
||||
@ -1300,7 +1300,6 @@ match_function(const long *f, int pos, FILE *file)
|
||||
unsigned char buf[FUNCTION_CONTEXT_SIZE];
|
||||
size_t nc;
|
||||
int last = lastline;
|
||||
char *p;
|
||||
char *state = NULL;
|
||||
|
||||
lastline = pos;
|
||||
@ -1312,9 +1311,8 @@ match_function(const long *f, int pos, FILE *file)
|
||||
nc = fread(buf, 1, nc, file);
|
||||
if (nc > 0) {
|
||||
buf[nc] = '\0';
|
||||
p = strchr(buf, '\n');
|
||||
if (p != NULL)
|
||||
*p = '\0';
|
||||
buf[strcspn(buf, "\n")] = '\0';
|
||||
|
||||
if (isalpha(buf[0]) || buf[0] == '_' || buf[0] == '$') {
|
||||
if (begins_with(buf, "private:")) {
|
||||
if (!state)
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: print.c,v 1.11 2004/05/19 02:32:35 tedu Exp $ */
|
||||
/* $OpenBSD: print.c,v 1.12 2007/09/11 15:47:17 gilles Exp $ */
|
||||
/*
|
||||
* Copyright (c) Ian F. Darwin 1986-1995.
|
||||
* Software written by Ian F. Darwin and others;
|
||||
@ -42,7 +42,7 @@
|
||||
#include <time.h>
|
||||
|
||||
#ifndef lint
|
||||
FILE_RCSID("@(#)$Id: print.c,v 1.11 2004/05/19 02:32:35 tedu Exp $")
|
||||
FILE_RCSID("@(#)$Id: print.c,v 1.12 2007/09/11 15:47:17 gilles Exp $")
|
||||
#endif /* lint */
|
||||
|
||||
#define SZOF(a) (sizeof(a) / sizeof(a[0]))
|
||||
@ -181,7 +181,6 @@ file_fmttime(uint32_t v, int local)
|
||||
pp = asctime(tm);
|
||||
}
|
||||
|
||||
if ((rt = strchr(pp, '\n')) != NULL)
|
||||
*rt = '\0';
|
||||
pp[strcspn(pp, "\n")] = '\0';
|
||||
return pp;
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: softmagic.c,v 1.11 2004/05/19 02:32:36 tedu Exp $ */
|
||||
/* $OpenBSD: softmagic.c,v 1.12 2007/09/11 15:47:17 gilles Exp $ */
|
||||
/*
|
||||
* Copyright (c) Ian F. Darwin 1986-1995.
|
||||
* Software written by Ian F. Darwin and others;
|
||||
@ -40,7 +40,7 @@
|
||||
|
||||
|
||||
#ifndef lint
|
||||
FILE_RCSID("@(#)$Id: softmagic.c,v 1.11 2004/05/19 02:32:36 tedu Exp $")
|
||||
FILE_RCSID("@(#)$Id: softmagic.c,v 1.12 2007/09/11 15:47:17 gilles Exp $")
|
||||
#endif /* lint */
|
||||
|
||||
private int match(struct magic_set *, struct magic *, uint32_t,
|
||||
@ -278,11 +278,8 @@ mprint(struct magic_set *ms, union VALUETYPE *p, struct magic *m)
|
||||
t = m->offset + strlen(m->value.s);
|
||||
}
|
||||
else {
|
||||
if (*m->value.s == '\0') {
|
||||
char *cp = strchr(p->s,'\n');
|
||||
if (cp)
|
||||
*cp = '\0';
|
||||
}
|
||||
if (*m->value.s == '\0')
|
||||
p->s[strcspn(p->s, "\n")] = '\0';
|
||||
if (file_printf(ms, m->desc, p->s) == -1)
|
||||
return -1;
|
||||
t = m->offset + strlen(p->s);
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: cmds.c,v 1.56 2007/07/26 17:48:41 millert Exp $ */
|
||||
/* $OpenBSD: cmds.c,v 1.57 2007/09/11 15:47:17 gilles Exp $ */
|
||||
/* $NetBSD: cmds.c,v 1.27 1997/08/18 10:20:15 lukem Exp $ */
|
||||
|
||||
/*
|
||||
@ -60,7 +60,7 @@
|
||||
*/
|
||||
|
||||
#if !defined(lint) && !defined(SMALL)
|
||||
static const char rcsid[] = "$OpenBSD: cmds.c,v 1.56 2007/07/26 17:48:41 millert Exp $";
|
||||
static const char rcsid[] = "$OpenBSD: cmds.c,v 1.57 2007/09/11 15:47:17 gilles Exp $";
|
||||
#endif /* not lint and not SMALL */
|
||||
|
||||
/*
|
||||
@ -1272,14 +1272,13 @@ user(int argc, char *argv[])
|
||||
}
|
||||
if (n == CONTINUE) {
|
||||
if (argc < 4) {
|
||||
char *p;
|
||||
|
||||
(void)fputs("Account: ", ttyout);
|
||||
(void)fflush(ttyout);
|
||||
if (fgets(acctname, sizeof(acctname), stdin) == NULL)
|
||||
goto fail;
|
||||
if ((p = strchr(acctname, '\n')) != NULL)
|
||||
*p = '\0';
|
||||
|
||||
acctname[strcspn(acctname, "\n")] = '\0';
|
||||
|
||||
argv[3] = acctname;
|
||||
argc++;
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: util.c,v 1.46 2007/06/06 19:15:33 pyr Exp $ */
|
||||
/* $OpenBSD: util.c,v 1.47 2007/09/11 15:47:17 gilles Exp $ */
|
||||
/* $NetBSD: util.c,v 1.12 1997/08/18 10:20:27 lukem Exp $ */
|
||||
|
||||
/*-
|
||||
@ -71,7 +71,7 @@
|
||||
*/
|
||||
|
||||
#if !defined(lint) && !defined(SMALL)
|
||||
static const char rcsid[] = "$OpenBSD: util.c,v 1.46 2007/06/06 19:15:33 pyr Exp $";
|
||||
static const char rcsid[] = "$OpenBSD: util.c,v 1.47 2007/09/11 15:47:17 gilles Exp $";
|
||||
#endif /* not lint and not SMALL */
|
||||
|
||||
/*
|
||||
@ -312,10 +312,7 @@ tryagain:
|
||||
fprintf(ttyout, "Name (%s): ", host);
|
||||
user = myname;
|
||||
if (fgets(tmp, sizeof(tmp), stdin) != NULL) {
|
||||
char *p;
|
||||
|
||||
if ((p = strchr(tmp, '\n')) != NULL)
|
||||
*p = '\0';
|
||||
tmp[strcspn(tmp, "\n")] = '\0';
|
||||
if (tmp[0] != '\0')
|
||||
user = tmp;
|
||||
}
|
||||
@ -469,8 +466,9 @@ remglob(char *argv[], int doswitch, char **errbuf)
|
||||
ftemp = NULL;
|
||||
return (NULL);
|
||||
}
|
||||
if ((cp = strchr(buf, '\n')) != NULL)
|
||||
*cp = '\0';
|
||||
|
||||
buf[strcspn(buf, "\n")] = '\0';
|
||||
|
||||
return (buf);
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: sign.c,v 1.7 2006/04/17 09:36:56 moritz Exp $ */
|
||||
/* $OpenBSD: sign.c,v 1.8 2007/09/11 15:47:17 gilles Exp $ */
|
||||
|
||||
/*
|
||||
* sign.c
|
||||
@ -200,8 +200,7 @@ sign_passwd_cb(char *buf, int size, int rwflag, void *u)
|
||||
if (fgets(buf, size, f) == NULL)
|
||||
err(1, "fgets(%.64s)", passphrase_file);
|
||||
fclose(f);
|
||||
if ((p = strchr(buf, '\n')) != NULL)
|
||||
*p = '\0';
|
||||
buf[strcspn(buf, "\n")] = '\0';
|
||||
} else {
|
||||
p = getpass("Enter passphrase: ");
|
||||
if (strlcpy(buf, p, size) >= size)
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: dired.c,v 1.42 2006/11/01 06:02:29 ray Exp $ */
|
||||
/* $OpenBSD: dired.c,v 1.43 2007/09/11 15:47:17 gilles Exp $ */
|
||||
|
||||
/* This file is in the public domain. */
|
||||
|
||||
@ -622,10 +622,7 @@ dired_(char *dname)
|
||||
}
|
||||
line[0] = line[1] = ' ';
|
||||
while (fgets(&line[2], sizeof(line) - 2, dirpipe) != NULL) {
|
||||
char *p;
|
||||
|
||||
if ((p = strchr(line, '\n')) != NULL)
|
||||
*p = '\0'; /* remove ^J */
|
||||
line[strcspn(line, "\n")] = '\0'; /* remove ^J */
|
||||
(void) addline(bp, line);
|
||||
}
|
||||
if (pclose(dirpipe) == -1) {
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: diff.c,v 1.24 2007/07/03 00:56:23 ray Exp $ */
|
||||
/* $OpenBSD: diff.c,v 1.25 2007/09/11 15:47:17 gilles Exp $ */
|
||||
/*
|
||||
* Copyright (C) Caldera International Inc. 2001-2002.
|
||||
* All rights reserved.
|
||||
@ -1155,7 +1155,6 @@ match_function(const long *f, int pos, FILE *fp)
|
||||
unsigned char buf[FUNCTION_CONTEXT_SIZE];
|
||||
size_t nc;
|
||||
int last = lastline;
|
||||
char *p;
|
||||
char *state = NULL;
|
||||
|
||||
lastline = pos;
|
||||
@ -1167,9 +1166,9 @@ match_function(const long *f, int pos, FILE *fp)
|
||||
nc = fread(buf, 1, nc, fp);
|
||||
if (nc > 0) {
|
||||
buf[nc] = '\0';
|
||||
p = strchr((const char *)buf, '\n');
|
||||
if (p != NULL)
|
||||
*p = '\0';
|
||||
|
||||
buf[strcspn(buf, "\n")] = '\0';
|
||||
|
||||
if (isalpha(buf[0]) || buf[0] == '_' || buf[0] == '$') {
|
||||
if (begins_with(buf, "private:")) {
|
||||
if (!state)
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: message.c,v 1.15 2003/06/03 02:56:14 millert Exp $ */
|
||||
/* $OpenBSD: message.c,v 1.16 2007/09/11 15:47:17 gilles Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1983 Regents of the University of California.
|
||||
@ -37,7 +37,7 @@ static char RCSid[] __attribute__((__unused__)) =
|
||||
"$From: message.c,v 1.5 1999/11/01 00:21:39 christos Exp $";
|
||||
#else
|
||||
static char RCSid[] __attribute__((__unused__)) =
|
||||
"$OpenBSD: message.c,v 1.15 2003/06/03 02:56:14 millert Exp $";
|
||||
"$OpenBSD: message.c,v 1.16 2007/09/11 15:47:17 gilles Exp $";
|
||||
#endif
|
||||
|
||||
static char sccsid[] __attribute__((__unused__)) =
|
||||
@ -517,8 +517,7 @@ _message(int flags, char *msgbuf)
|
||||
/*
|
||||
* Ensure no stray newlines are present
|
||||
*/
|
||||
if ((cp = strchr(msgbuf, '\n')) != NULL)
|
||||
*cp = CNULL;
|
||||
msgbuf[strcspn(msgbuf, "\n")] = CNULL;
|
||||
|
||||
checkhostname();
|
||||
if (strncmp(currenthost, msgbuf, strlen(currenthost)) == 0)
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: session.c,v 1.223 2007/08/23 02:55:51 djm Exp $ */
|
||||
/* $OpenBSD: session.c,v 1.224 2007/09/11 15:47:17 gilles Exp $ */
|
||||
/*
|
||||
* Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
|
||||
* All rights reserved
|
||||
@ -724,8 +724,9 @@ read_environment_file(char ***env, u_int *envsize,
|
||||
;
|
||||
if (!*cp || *cp == '#' || *cp == '\n')
|
||||
continue;
|
||||
if (strchr(cp, '\n'))
|
||||
*strchr(cp, '\n') = '\0';
|
||||
|
||||
cp[strcspn(cp, "\n")] = '\0';
|
||||
|
||||
value = strchr(cp, '=');
|
||||
if (value == NULL) {
|
||||
fprintf(stderr, "Bad line %u in %.100s\n", lineno,
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: ssh-keygen.c,v 1.161 2007/09/09 11:38:01 sobrado Exp $ */
|
||||
/* $OpenBSD: ssh-keygen.c,v 1.162 2007/09/11 15:47:17 gilles Exp $ */
|
||||
/*
|
||||
* Author: Tatu Ylonen <ylo@cs.hut.fi>
|
||||
* Copyright (c) 1994 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
|
||||
@ -134,8 +134,7 @@ ask_filename(struct passwd *pw, const char *prompt)
|
||||
fprintf(stderr, "%s (%s): ", prompt, identity_file);
|
||||
if (fgets(buf, sizeof(buf), stdin) == NULL)
|
||||
exit(1);
|
||||
if (strchr(buf, '\n'))
|
||||
*strchr(buf, '\n') = 0;
|
||||
buf[strcspn(buf, "\n")] = '\0';
|
||||
if (strcmp(buf, "") != 0)
|
||||
strlcpy(identity_file, buf, sizeof(identity_file));
|
||||
have_identity = 1;
|
||||
@ -955,8 +954,7 @@ do_change_comment(struct passwd *pw)
|
||||
key_free(private);
|
||||
exit(1);
|
||||
}
|
||||
if (strchr(new_comment, '\n'))
|
||||
*strchr(new_comment, '\n') = 0;
|
||||
new_comment[strcspn(new_comment, "\n")] = '\0';
|
||||
}
|
||||
|
||||
/* Save the file using the new passphrase. */
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: sshlogin.c,v 1.25 2006/08/03 03:34:42 deraadt Exp $ */
|
||||
/* $OpenBSD: sshlogin.c,v 1.26 2007/09/11 15:47:17 gilles Exp $ */
|
||||
/*
|
||||
* Author: Tatu Ylonen <ylo@cs.hut.fi>
|
||||
* Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
|
||||
@ -122,8 +122,7 @@ store_lastlog_message(const char *user, uid_t uid)
|
||||
|
||||
if (last_login_time != 0) {
|
||||
time_string = ctime(&last_login_time);
|
||||
if (strchr(time_string, '\n'))
|
||||
*strchr(time_string, '\n') = '\0';
|
||||
time_string[strcspn(time_string, "\n")] = '\0';
|
||||
if (strcmp(hostname, "") == 0)
|
||||
snprintf(buf, sizeof(buf), "Last login: %s\r\n",
|
||||
time_string);
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: scan.c,v 1.15 2003/07/10 00:06:51 david Exp $ */
|
||||
/* $OpenBSD: scan.c,v 1.16 2007/09/11 15:47:17 gilles Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1992 Carnegie Mellon University
|
||||
@ -302,9 +302,7 @@ getrelease (release)
|
||||
rewound = TRUE;
|
||||
continue;
|
||||
}
|
||||
q = strchr(p, '\n');
|
||||
if (q)
|
||||
*q = '\0';
|
||||
p[strcspn(p, "\n")] = '\0';
|
||||
if (strchr("#;:", *p))
|
||||
continue;
|
||||
q = nxtarg(&p, " \t");
|
||||
@ -350,9 +348,7 @@ makescanlists()
|
||||
f = fopen(buf, "r");
|
||||
if (f != NULL) {
|
||||
while ((p = fgets(buf, sizeof(buf), f)) != NULL) {
|
||||
q = strchr(p,'\n');
|
||||
if (q)
|
||||
*q = '\0';
|
||||
p[strcspn(p, "\n")] = '\0';
|
||||
if (strchr("#;:", *p))
|
||||
continue;
|
||||
q = nxtarg(&p, " \t");
|
||||
@ -479,8 +475,7 @@ readlistfile(fname)
|
||||
goaway("Can't read list file %s", fname);
|
||||
cdprefix(prefix);
|
||||
while ((p = fgets(buf, sizeof(buf), f)) != NULL) {
|
||||
if ((q = strchr(p, '\n')) != NULL)
|
||||
*q = '\0';
|
||||
p[strcspn(p, "\n")] = '\0';
|
||||
if (strchr("#;:", *p))
|
||||
continue;
|
||||
q = nxtarg (&p, " \t");
|
||||
@ -869,8 +864,9 @@ int getscanfile(scanfile)
|
||||
(void) fclose(f);
|
||||
return (FALSE);
|
||||
}
|
||||
if ((q = strchr(p,'\n')) != NULL)
|
||||
*q = '\0';
|
||||
|
||||
p[strcspn(p, "\n")] = '\0';
|
||||
|
||||
if (*p++ != 'V') {
|
||||
(void) fclose(f);
|
||||
return (FALSE);
|
||||
@ -887,9 +883,7 @@ int getscanfile(scanfile)
|
||||
}
|
||||
notwanted = FALSE;
|
||||
while ((p = fgets(buf, sizeof(buf), f)) != NULL) {
|
||||
q = strchr(p, '\n');
|
||||
if (q)
|
||||
*q = '\0';
|
||||
p[strcspn(p, "\n")] = '\0';
|
||||
ts.Tflags = 0;
|
||||
if (*p == 'X') {
|
||||
if (notwanted)
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: supcmain.c,v 1.20 2005/04/27 18:13:16 mickey Exp $ */
|
||||
/* $OpenBSD: supcmain.c,v 1.21 2007/09/11 15:47:17 gilles Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1992 Carnegie Mellon University
|
||||
@ -666,8 +666,7 @@ init(argc, argv)
|
||||
lastC = NULL;
|
||||
bogus = FALSE;
|
||||
while ((p = fgets(buf, sizeof(buf), f)) != NULL) {
|
||||
if ((q = strchr(p, '\n')))
|
||||
*q = '\0';
|
||||
p[strcspn(p, "\n")] = '\0';
|
||||
if (strchr("#;:", *p))
|
||||
continue;
|
||||
arg = nxtarg (&p, " \t");
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: supcmeat.c,v 1.21 2005/04/27 18:13:16 mickey Exp $ */
|
||||
/* $OpenBSD: supcmeat.c,v 1.22 2007/09/11 15:47:17 gilles Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1992 Carnegie Mellon University
|
||||
@ -501,8 +501,7 @@ listfiles()
|
||||
f = fopen(buf, "r");
|
||||
if (f) {
|
||||
while ((p = fgets(buf, sizeof(buf), f)) != NULL) {
|
||||
if ((q = strchr(p, '\n')))
|
||||
*q = '\0';
|
||||
p[strcspn(p, "\n")] = '\0';
|
||||
if (strchr("#;:", *p))
|
||||
continue;
|
||||
(void) Tinsert(&lastT, p, FALSE);
|
||||
@ -514,8 +513,7 @@ listfiles()
|
||||
f = fopen(buf, "r");
|
||||
if (f) {
|
||||
while ((p = fgets(buf, sizeof(buf), f)) != NULL) {
|
||||
if ((q = strchr(p, '\n')))
|
||||
*q = '\0';
|
||||
p[strcspn(p, "\n")] = '\0';
|
||||
if (strchr("#;:", *p))
|
||||
continue;
|
||||
(void) Tinsert(&refuseT, p, FALSE);
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: supcname.c,v 1.7 2001/05/04 22:16:16 millert Exp $ */
|
||||
/* $OpenBSD: supcname.c,v 1.8 2007/09/11 15:47:17 gilles Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1992 Carnegie Mellon University
|
||||
@ -83,8 +83,7 @@ getnams()
|
||||
if (f == NULL)
|
||||
logquit (1, "Can't open %s", buf);
|
||||
while ((p = fgets(buf, sizeof(buf), f)) != NULL) {
|
||||
if ((q = strchr(p, '\n')) != NULL)
|
||||
*q = '\0';
|
||||
p[strcspn(p, "\n")] = '\0';
|
||||
if (strchr("#;:", *p))
|
||||
continue;
|
||||
q = nxtarg(&p, "= \t");
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: supfilesrv.c,v 1.36 2006/03/04 16:18:06 miod Exp $ */
|
||||
/* $OpenBSD: supfilesrv.c,v 1.37 2007/09/11 15:47:17 gilles Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1992 Carnegie Mellon University
|
||||
@ -637,11 +637,13 @@ init(argc, argv)
|
||||
if (f == NULL)
|
||||
quit(1, "Unable to open cryptfile %s\n", cryptkey);
|
||||
if ((p = fgets(buf, sizeof(buf), f)) != NULL) {
|
||||
if ((q = strchr(p, '\n')))
|
||||
*q = '\0';
|
||||
p[strcspn(p, "\n")] = '\0';
|
||||
if (*p == '\0')
|
||||
quit(1, "No cryptkey found in %s\n", cryptkey);
|
||||
cryptkey = strdup(buf);
|
||||
if (cryptkey == NULL)
|
||||
quit(1, "Unable to allocate memory\n");
|
||||
|
||||
}
|
||||
(void) fclose(f);
|
||||
x = request (dbgportsq ? DEBUGFPORT : FILEPORT, clienthost, &maxsleep);
|
||||
@ -864,9 +866,7 @@ srvsetup()
|
||||
struct stat fsbuf;
|
||||
|
||||
while ((p = fgets(buf, sizeof(buf), f)) != NULL) {
|
||||
q = strchr(p, '\n');
|
||||
if (q)
|
||||
*q = '\0';
|
||||
p[strcspn(p, "\n")] = '\0';
|
||||
if (strchr("#;:", *p))
|
||||
continue;
|
||||
q = nxtarg(&p, " \t");
|
||||
@ -922,9 +922,7 @@ srvsetup()
|
||||
f = fopen(buf, "r");
|
||||
if (f) {
|
||||
while ((p = fgets(buf, sizeof(buf), f)) != NULL) {
|
||||
q = strchr(p, '\n');
|
||||
if (q)
|
||||
*q = '\0';
|
||||
p[strcspn(p, "\n")] = '\0';
|
||||
if (strchr("#;:", *p))
|
||||
continue;
|
||||
q = nxtarg(&p, " \t=");
|
||||
@ -948,9 +946,7 @@ srvsetup()
|
||||
f = fopen(buf, "r");
|
||||
if (f) {
|
||||
while ((p = fgets(buf, sizeof(buf), f)) != NULL) {
|
||||
q = strchr(p, '\n');
|
||||
if (q)
|
||||
*q = '\0';
|
||||
p[strcspn(p, "\n")] = '\0';
|
||||
if (strchr("#;:", *p))
|
||||
continue;
|
||||
prefix = strdup(p);
|
||||
@ -1002,9 +998,7 @@ srvsetup()
|
||||
while ((p = fgets (buf, sizeof(buf), f)) != NULL) {
|
||||
int not;
|
||||
|
||||
q = strchr (p,'\n');
|
||||
if (q)
|
||||
*q = '\0';
|
||||
p[strcspn(p, "\n")] = '\0';
|
||||
if (strchr("#;:", *p))
|
||||
continue;
|
||||
q = nxtarg(&p, " \t");
|
||||
@ -1080,8 +1074,7 @@ docrypt()
|
||||
|
||||
if (cryptkey == NULL &&
|
||||
(p = fgets(buf, sizeof(buf), f))) {
|
||||
if ((q = strchr(p, '\n')) != NULL)
|
||||
*q = '\0';
|
||||
p[strcspn(p, "\n")] = '\0';
|
||||
if (*p)
|
||||
cryptkey = strdup(buf);
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: supscan.c,v 1.14 2006/01/23 17:29:22 millert Exp $ */
|
||||
/* $OpenBSD: supscan.c,v 1.15 2007/09/11 15:47:17 gilles Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1992 Carnegie Mellon University
|
||||
@ -276,9 +276,7 @@ init(argc, argv)
|
||||
if ((f = fopen(buf, "r")) == NULL)
|
||||
quit(1, "supscan: Unable to open %s\n", buf);
|
||||
while ((p = fgets(buf, sizeof(buf), f)) != NULL) {
|
||||
q = strchr(p, '\n');
|
||||
if (q)
|
||||
*q = '\0';
|
||||
p[strcspn(p, "\n")] = '\0';
|
||||
if (strchr("#;:", *p))
|
||||
continue;
|
||||
collname = nxtarg(&p, " \t=");
|
||||
@ -298,9 +296,7 @@ init(argc, argv)
|
||||
if ((f = fopen(filename, "r")) == NULL)
|
||||
quit(1, "supscan: Unable to open %s\n", filename);
|
||||
while ((p = fgets(buf, sizeof(buf), f)) != NULL) {
|
||||
q = strchr(p, '\n');
|
||||
if (q)
|
||||
*q = '\0';
|
||||
p[strcspn(p, "\n")] = '\0';
|
||||
if (strchr("#;:",*p))
|
||||
continue;
|
||||
q = nxtarg(&p, " \t=");
|
||||
@ -329,9 +325,7 @@ getscancoll(filename, collname, basedir)
|
||||
if (basedir == NULL) {
|
||||
if ((f = fopen(filename, "r")) != NULL) {
|
||||
while ((p = fgets(buf, sizeof(buf), f)) != NULL) {
|
||||
q = strchr(p, '\n');
|
||||
if (q)
|
||||
*q = '\0';
|
||||
p[strcspn(p, "\n")] = '\0';
|
||||
if (strchr("#;:", *p))
|
||||
continue;
|
||||
q = nxtarg(&p, " \t=");
|
||||
@ -359,9 +353,7 @@ getscancoll(filename, collname, basedir)
|
||||
(void) snprintf(buf, sizeof buf, FILEPREFIX, collname);
|
||||
if ((f = fopen(buf, "r")) != NULL) {
|
||||
while ((p = fgets(buf, sizeof(buf), f)) != NULL) {
|
||||
q = strchr(p, '\n');
|
||||
if (q)
|
||||
*q = '\0';
|
||||
p[strcspn(p, "\n")] = '\0';
|
||||
if (strchr("#;:", *p))
|
||||
continue;
|
||||
prefix = strdup(p);
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: disks.c,v 1.16 2007/03/20 03:56:13 tedu Exp $ */
|
||||
/* $OpenBSD: disks.c,v 1.17 2007/09/11 15:47:17 gilles Exp $ */
|
||||
/* $NetBSD: disks.c,v 1.4 1996/05/10 23:16:33 thorpej Exp $ */
|
||||
|
||||
/*-
|
||||
@ -34,7 +34,7 @@
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)disks.c 8.1 (Berkeley) 6/6/93";
|
||||
#endif
|
||||
static char rcsid[] = "$OpenBSD: disks.c,v 1.16 2007/03/20 03:56:13 tedu Exp $";
|
||||
static char rcsid[] = "$OpenBSD: disks.c,v 1.17 2007/09/11 15:47:17 gilles Exp $";
|
||||
#endif /* not lint */
|
||||
|
||||
#include <string.h>
|
||||
@ -74,9 +74,8 @@ dkselect(char *args, int truefalse, int selections[])
|
||||
char *cp;
|
||||
int i;
|
||||
|
||||
cp = strchr(args, '\n');
|
||||
if (cp)
|
||||
*cp = '\0';
|
||||
args[strcspn(args, "\n")] = '\0';
|
||||
|
||||
for (;;) {
|
||||
for (cp = args; isspace(*cp); cp++)
|
||||
;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: netcmds.c,v 1.18 2007/08/09 02:38:09 ray Exp $ */
|
||||
/* $OpenBSD: netcmds.c,v 1.19 2007/09/11 15:47:17 gilles Exp $ */
|
||||
/* $NetBSD: netcmds.c,v 1.4 1995/05/21 17:14:38 mycroft Exp $ */
|
||||
|
||||
/*-
|
||||
@ -34,7 +34,7 @@
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)netcmds.c 8.1 (Berkeley) 6/6/93";
|
||||
#endif
|
||||
static char rcsid[] = "$OpenBSD: netcmds.c,v 1.18 2007/08/09 02:38:09 ray Exp $";
|
||||
static char rcsid[] = "$OpenBSD: netcmds.c,v 1.19 2007/09/11 15:47:17 gilles Exp $";
|
||||
#endif /* not lint */
|
||||
|
||||
/*
|
||||
@ -129,9 +129,8 @@ changeitems(char *args, int onoff)
|
||||
struct servent *sp;
|
||||
struct addrinfo hints, *res0, *res;
|
||||
|
||||
cp = strchr(args, '\n');
|
||||
if (cp)
|
||||
*cp = '\0';
|
||||
args[strcspn(args, "\n")] = '\0';
|
||||
|
||||
for (;;args = cp) {
|
||||
for (cp = args; isspace(*cp); cp++)
|
||||
;
|
||||
|
@ -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)
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: vacation.c,v 1.29 2007/03/21 03:31:19 tedu Exp $ */
|
||||
/* $OpenBSD: vacation.c,v 1.30 2007/09/11 15:47:17 gilles Exp $ */
|
||||
/* $NetBSD: vacation.c,v 1.7 1995/04/29 05:58:27 cgd Exp $ */
|
||||
|
||||
/*
|
||||
@ -40,7 +40,7 @@ static char copyright[] =
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)vacation.c 8.2 (Berkeley) 1/26/94";
|
||||
#endif
|
||||
static char rcsid[] = "$OpenBSD: vacation.c,v 1.29 2007/03/21 03:31:19 tedu Exp $";
|
||||
static char rcsid[] = "$OpenBSD: vacation.c,v 1.30 2007/09/11 15:47:17 gilles Exp $";
|
||||
#endif /* not lint */
|
||||
|
||||
/*
|
||||
@ -235,8 +235,7 @@ readheaders(void)
|
||||
;
|
||||
*p = '\0';
|
||||
(void)strlcpy(from, buf + 5, sizeof(from));
|
||||
if ((p = strchr(from, '\n')))
|
||||
*p = '\0';
|
||||
from[strcspn(from, "\n")] = '\0';
|
||||
if (junkmail())
|
||||
exit(0);
|
||||
}
|
||||
@ -265,8 +264,7 @@ readheaders(void)
|
||||
"Return-Path %s exceeds limits", p);
|
||||
exit(1);
|
||||
}
|
||||
if ((p = strchr(from, '\n')))
|
||||
*p = '\0';
|
||||
from[strcspn(from, "\n")] = '\0';
|
||||
if (junkmail())
|
||||
exit(0);
|
||||
break;
|
||||
@ -296,8 +294,7 @@ readheaders(void)
|
||||
"Subject %s exceeds limits", p);
|
||||
exit(1);
|
||||
}
|
||||
if ((p = strchr(subj, '\n')))
|
||||
*p = '\0';
|
||||
subj[strcspn(subj, "\n")] = '\0';
|
||||
break;
|
||||
case 'C': /* "Cc:" */
|
||||
case 'c':
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: recover.c,v 1.11 2006/12/11 20:50:55 deraadt Exp $ */
|
||||
/* $OpenBSD: recover.c,v 1.12 2007/09/11 15:47:17 gilles Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1993, 1994
|
||||
@ -817,8 +817,7 @@ rcv_gets(buf, len, fd)
|
||||
if ((nr = read(fd, buf, len - 1)) == -1)
|
||||
return (NULL);
|
||||
buf[nr] = '\0';
|
||||
if ((p = strchr(buf, '\n')) == NULL)
|
||||
return (NULL);
|
||||
buf[strcspn(buf, "\n")] = '\0';
|
||||
(void)lseek(fd, (off_t)((p - buf) + 1), SEEK_SET);
|
||||
return (buf);
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: ex_cscope.c,v 1.13 2007/03/20 03:56:13 tedu Exp $ */
|
||||
/* $OpenBSD: ex_cscope.c,v 1.14 2007/09/11 15:47:17 gilles Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1994, 1996
|
||||
@ -675,8 +675,7 @@ parse(sp, csc, tqp, matchesp)
|
||||
#define CSCOPE_NLINES_FMT "cscope: %d lines%1[\n]"
|
||||
if (sscanf(buf, CSCOPE_NLINES_FMT, &nlines, dummy) == 2)
|
||||
break;
|
||||
if ((p = strchr(buf, '\n')) != NULL)
|
||||
*p = '\0';
|
||||
buf[strcspn(buf, "\n")] = '\0';
|
||||
msgq(sp, M_ERR, "%s: \"%s\"", csc->dname, buf);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user