summaryrefslogtreecommitdiff
path: root/bin/ed/io.c
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>1996-09-15 22:25:59 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>1996-09-15 22:25:59 +0000
commit733966b6e5cfde760f42ebed60f7e0efeeddf8cb (patch)
tree548a078905be8e1a2203de6ba51212c3c5a99a13 /bin/ed/io.c
parentecc60413067be65a5816bbc9c21e9e389b2d6fac (diff)
sprintf -> snprintf paranoia
Diffstat (limited to 'bin/ed/io.c')
-rw-r--r--bin/ed/io.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/bin/ed/io.c b/bin/ed/io.c
index a05e96a3a9e..fbf1b3cd9d9 100644
--- a/bin/ed/io.c
+++ b/bin/ed/io.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: io.c,v 1.2 1996/06/23 14:20:02 deraadt Exp $ */
+/* $OpenBSD: io.c,v 1.3 1996/09/15 22:25:56 millert Exp $ */
/* $NetBSD: io.c,v 1.2 1995/03/21 09:04:43 cgd Exp $ */
/* io.c: This file contains the i/o routines for the ed line editor */
@@ -32,7 +32,7 @@
#if 0
static char *rcsid = "@(#)io.c,v 1.1 1994/02/01 00:34:41 alm Exp";
#else
-static char rcsid[] = "$OpenBSD: io.c,v 1.2 1996/06/23 14:20:02 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: io.c,v 1.3 1996/09/15 22:25:56 millert Exp $";
#endif
#endif /* not lint */
@@ -54,13 +54,13 @@ read_file(fn, n)
fp = (*fn == '!') ? popen(fn + 1, "r") : fopen(strip_escapes(fn), "r");
if (fp == NULL) {
fprintf(stderr, "%s: %s\n", fn, strerror(errno));
- sprintf(errmsg, "cannot open input file");
+ snprintf(errmsg, sizeof(errmsg), "cannot open input file");
return ERR;
} else if ((size = read_stream(fp, n)) < 0)
return ERR;
else if (((*fn == '!') ? pclose(fp) : fclose(fp)) < 0) {
fprintf(stderr, "%s: %s\n", fn, strerror(errno));
- sprintf(errmsg, "cannot close input file");
+ snprintf(errmsg, sizeof(errmsg), "cannot close input file");
return ERR;
}
fprintf(stderr, !scripted ? "%lu\n" : "", size);
@@ -144,7 +144,7 @@ get_stream_line(fp)
sbuf[i++] = c;
else if (ferror(fp)) {
fprintf(stderr, "%s\n", strerror(errno));
- sprintf(errmsg, "cannot read input file");
+ snprintf(errmsg, sizeof(errmsg), "cannot read input file");
return ERR;
} else if (i) {
sbuf[i++] = '\n';
@@ -169,13 +169,13 @@ write_file(fn, mode, n, m)
fp = (*fn == '!') ? popen(fn+1, "w") : fopen(strip_escapes(fn), mode);
if (fp == NULL) {
fprintf(stderr, "%s: %s\n", fn, strerror(errno));
- sprintf(errmsg, "cannot open output file");
+ snprintf(errmsg, sizeof(errmsg), "cannot open output file");
return ERR;
} else if ((size = write_stream(fp, n, m)) < 0)
return ERR;
else if (((*fn == '!') ? pclose(fp) : fclose(fp)) < 0) {
fprintf(stderr, "%s: %s\n", fn, strerror(errno));
- sprintf(errmsg, "cannot close output file");
+ snprintf(errmsg, sizeof(errmsg), "cannot close output file");
return ERR;
}
fprintf(stderr, !scripted ? "%lu\n" : "", size);
@@ -225,7 +225,7 @@ put_stream_line(fp, s, len)
while (len--)
if ((des ? put_des_char(*s++, fp) : fputc(*s++, fp)) < 0) {
fprintf(stderr, "%s\n", strerror(errno));
- sprintf(errmsg, "cannot write file");
+ snprintf(errmsg, sizeof(errmsg), "cannot write file");
return ERR;
}
return 0;
@@ -258,7 +258,7 @@ get_extended_line(sizep, nonl)
if ((n = get_tty_line()) < 0)
return NULL;
else if (n == 0 || ibuf[n - 1] != '\n') {
- sprintf(errmsg, "unexpected end-of-file");
+ snprintf(errmsg, sizeof(errmsg), "unexpected end-of-file");
return NULL;
}
REALLOC(cvbuf, cvbufsz, l + n, NULL);
@@ -299,7 +299,7 @@ get_tty_line()
case EOF:
if (ferror(stdin)) {
fprintf(stderr, "stdin: %s\n", strerror(errno));
- sprintf(errmsg, "cannot read stdin");
+ snprintf(errmsg, sizeof(errmsg), "cannot read stdin");
clearerr(stdin);
ibufp = NULL;
return ERR;