diff options
-rw-r--r-- | usr.bin/mg/dir.c | 4 | ||||
-rw-r--r-- | usr.bin/mg/dired.c | 8 | ||||
-rw-r--r-- | usr.bin/mg/extend.c | 7 | ||||
-rw-r--r-- | usr.bin/mg/file.c | 8 | ||||
-rw-r--r-- | usr.bin/mg/fileio.c | 9 | ||||
-rw-r--r-- | usr.bin/mg/line.c | 25 | ||||
-rw-r--r-- | usr.bin/mg/undo.c | 10 |
7 files changed, 39 insertions, 32 deletions
diff --git a/usr.bin/mg/dir.c b/usr.bin/mg/dir.c index 2383d711681..656b6c08f14 100644 --- a/usr.bin/mg/dir.c +++ b/usr.bin/mg/dir.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dir.c,v 1.15 2005/11/20 18:47:11 kjell Exp $ */ +/* $OpenBSD: dir.c,v 1.16 2005/12/20 05:04:28 kjell Exp $ */ /* This file is in the public domain. */ @@ -23,7 +23,7 @@ dirinit(void) if ((wdir = getcwd(cwd, sizeof(cwd))) == NULL) { ewprintf("Can't get current directory!"); chdir("/"); - strlcpy(cwd, "/", sizeof(cwd)); + (void)strlcpy(cwd, "/", sizeof(cwd)); } } diff --git a/usr.bin/mg/dired.c b/usr.bin/mg/dired.c index f276084229d..48b5aa1fe45 100644 --- a/usr.bin/mg/dired.c +++ b/usr.bin/mg/dired.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dired.c,v 1.34 2005/12/13 07:20:13 kjell Exp $ */ +/* $OpenBSD: dired.c,v 1.35 2005/12/20 05:04:28 kjell Exp $ */ /* This file is in the public domain. */ @@ -561,7 +561,8 @@ d_makename(struct line *lp, char *fn, size_t len) int i; char *p, *ep; - strlcpy(fn, curbp->b_fname, len); + if (strlcpy(fn, curbp->b_fname, len) >= len) + return (FALSE); if ((p = lp->l_text) == NULL) return (ABORT); ep = lp->l_text + llength(lp); @@ -576,7 +577,8 @@ d_makename(struct line *lp, char *fn, size_t len) if (p == ep) return (ABORT); } - strlcat(fn, p, len); + if (strlcat(fn, p, len) >= len) + return (FALSE); return ((lgetc(lp, 2) == 'd') ? TRUE : FALSE); } diff --git a/usr.bin/mg/extend.c b/usr.bin/mg/extend.c index 5f436d04aa9..217318ad870 100644 --- a/usr.bin/mg/extend.c +++ b/usr.bin/mg/extend.c @@ -1,4 +1,4 @@ -/* $OpenBSD: extend.c,v 1.42 2005/12/13 06:01:27 kjell Exp $ */ +/* $OpenBSD: extend.c,v 1.43 2005/12/20 05:04:28 kjell Exp $ */ /* This file is in the public domain. */ @@ -504,7 +504,7 @@ redefine_key(int f, int n) char tmp[32], *bufp; KEYMAP *mp; - strlcpy(buf, "Define key map: ", sizeof(buf)); + (void)strlcpy(buf, "Define key map: ", sizeof(buf)); if ((bufp = eread(buf, tmp, sizeof(tmp), EFNEW)) == NULL) return (ABORT); else if (bufp[0] == '\0') @@ -514,7 +514,8 @@ redefine_key(int f, int n) ewprintf("Unknown map %s", tmp); return (FALSE); } - strlcat(buf, "key: ", sizeof(buf)); + if (strlcat(buf, "key: ", sizeof(buf)) >= sizeof(buf)) + return (FALSE); return (dobind(mp, buf, FALSE)); } diff --git a/usr.bin/mg/file.c b/usr.bin/mg/file.c index b0bb0324721..79e8fcfd57e 100644 --- a/usr.bin/mg/file.c +++ b/usr.bin/mg/file.c @@ -1,4 +1,4 @@ -/* $OpenBSD: file.c,v 1.48 2005/12/13 06:01:27 kjell Exp $ */ +/* $OpenBSD: file.c,v 1.49 2005/12/20 05:04:28 kjell Exp $ */ /* This file is in the public domain. */ @@ -46,7 +46,8 @@ filevisit(int f, int n) int status; if (curbp->b_fname && curbp->b_fname[0] != '\0') { - strlcpy(fname, curbp->b_fname, sizeof(fname)); + if (strlcpy(fname, curbp->b_fname, sizeof(fname)) >= sizeof(fname)) + return (FALSE); if ((slash = strrchr(fname, '/')) != NULL) { *(slash + 1) = '\0'; } @@ -91,7 +92,8 @@ filevisitalt(int f, int n) int status; if (curbp->b_fname && curbp->b_fname[0] != '\0') { - strlcpy(fname, curbp->b_fname, sizeof(fname)); + if (strlcpy(fname, curbp->b_fname, sizeof(fname)) >= sizeof(fname)) + return (FALSE); if ((slash = strrchr(fname, '/')) != NULL) { *(slash + 1) = '\0'; } diff --git a/usr.bin/mg/fileio.c b/usr.bin/mg/fileio.c index 75ee6363608..9cc81311d42 100644 --- a/usr.bin/mg/fileio.c +++ b/usr.bin/mg/fileio.c @@ -1,4 +1,4 @@ -/* $OpenBSD: fileio.c,v 1.66 2005/12/13 05:40:33 kjell Exp $ */ +/* $OpenBSD: fileio.c,v 1.67 2005/12/20 05:04:28 kjell Exp $ */ /* This file is in the public domain. */ @@ -454,12 +454,13 @@ make_file_list(char *buf) return (NULL); } /* Now we get the prefix of the name the user typed. */ - strlcpy(prefixx, buf, sizeof(prefixx)); + if (strlcpy(prefixx, buf, sizeof(prefixx)) >= sizeof(prefixx)) + return (NULL); cp = strrchr(prefixx, '/'); if (cp == NULL) - prefixx[0] = 0; + prefixx[0] = '\0'; else - cp[1] = 0; + cp[1] = '\0'; preflen = strlen(prefixx); /* cp is the tail of buf that really needs to be compared. */ diff --git a/usr.bin/mg/line.c b/usr.bin/mg/line.c index 49a718d9c3a..f1bf4973c3c 100644 --- a/usr.bin/mg/line.c +++ b/usr.bin/mg/line.c @@ -1,4 +1,4 @@ -/* $OpenBSD: line.c,v 1.35 2005/12/20 04:58:10 kjell Exp $ */ +/* $OpenBSD: line.c,v 1.36 2005/12/20 05:04:28 kjell Exp $ */ /* This file is in the public domain. */ @@ -381,23 +381,24 @@ lnewline(void) } /* - * This function deletes "n" bytes, starting at dot. It understands how to - * deal with end of lines, etc. It returns TRUE if all of the characters - * were deleted, and FALSE if they were not (because dot ran into the end - * of the buffer. The "kflag" indicates either no insertion, or direction - * of insertion into the kill buffer. + * This function deletes "n" bytes, starting at dot. (actually, n+1, as the + * newline is included) It understands how to deal with end of lines, etc. + * It returns TRUE if all of the characters were deleted, and FALSE if + * they were not (because dot ran into the end of the buffer). + * The "kflag" indicates either no insertion, or direction of insertion + * into the kill buffer. */ int ldelete(RSIZE n, int kflag) { struct line *dotp; - RSIZE chunk; + RSIZE chunk; struct mgwin *wp; - int doto; - char *cp1, *cp2; - size_t len; - char *sv; - int end; + int doto; + char *cp1, *cp2; + size_t len; + char *sv; + int end; if (curbp->b_flag & BFREADONLY) { ewprintf("Buffer is read only"); diff --git a/usr.bin/mg/undo.c b/usr.bin/mg/undo.c index 15ccb15a35b..b6600d441e9 100644 --- a/usr.bin/mg/undo.c +++ b/usr.bin/mg/undo.c @@ -1,4 +1,4 @@ -/* $OpenBSD: undo.c,v 1.37 2005/12/13 07:20:13 kjell Exp $ */ +/* $OpenBSD: undo.c,v 1.38 2005/12/20 05:04:28 kjell Exp $ */ /* * Copyright (c) 2002 Vincent Labrecque <vincent@openbsd.org> * All rights reserved. @@ -371,18 +371,18 @@ undo_dump(int f, int n) rec = LIST_NEXT(rec, next)) { num++; snprintf(buf, sizeof(buf), - "Record %d =>\t %s at %d ", num, + "%d:\t %s at %d ", num, (rec->type == DELETE) ? "DELETE": (rec->type == INSERT) ? "INSERT": (rec->type == BOUNDARY) ? "----" : "UNKNOWN", rec->pos); if (rec->content) { - strlcat(buf, "\"", sizeof(buf)); + (void)strlcat(buf, "\"", sizeof(buf)); snprintf(tmp, sizeof(tmp), "%.*s", rec->region.r_size, rec->content); - strlcat(buf, tmp, sizeof(buf)); - strlcat(buf, "\"", sizeof(buf)); + (void)strlcat(buf, tmp, sizeof(buf)); + (void)strlcat(buf, "\"", sizeof(buf)); } snprintf(tmp, sizeof(tmp), " [%d]", rec->region.r_size); if (strlcat(buf, tmp, sizeof(buf)) >= sizeof(buf)) { |