Module Name: src
Committed By: christos
Date: Wed Oct 9 14:31:07 UTC 2019
Modified Files:
src/lib/libedit: filecomplete.c readline.c
Log Message:
add +1 to strlcpy's (Patrick Welche)
To generate a diff of this commit:
cvs rdiff -u -r1.60 -r1.61 src/lib/libedit/filecomplete.c
cvs rdiff -u -r1.158 -r1.159 src/lib/libedit/readline.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/lib/libedit/filecomplete.c
diff -u src/lib/libedit/filecomplete.c:1.60 src/lib/libedit/filecomplete.c:1.61
--- src/lib/libedit/filecomplete.c:1.60 Tue Oct 8 15:21:40 2019
+++ src/lib/libedit/filecomplete.c Wed Oct 9 10:31:07 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: filecomplete.c,v 1.60 2019/10/08 19:21:40 christos Exp $ */
+/* $NetBSD: filecomplete.c,v 1.61 2019/10/09 14:31:07 christos Exp $ */
/*-
* Copyright (c) 1997 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
#include "config.h"
#if !defined(lint) && !defined(SCCSID)
-__RCSID("$NetBSD: filecomplete.c,v 1.60 2019/10/08 19:21:40 christos Exp $");
+__RCSID("$NetBSD: filecomplete.c,v 1.61 2019/10/09 14:31:07 christos Exp $");
#endif /* not lint && not SCCSID */
#include <sys/types.h>
@@ -86,7 +86,7 @@ fn_tilde_expand(const char *txt)
temp = el_calloc(len, sizeof(*temp));
if (temp == NULL)
return NULL;
- (void)strlcpy(temp, txt + 1, len - 2);
+ (void)strlcpy(temp, txt + 1, len - 1);
}
if (temp[0] == 0) {
#ifdef HAVE_GETPW_R_POSIX
@@ -353,7 +353,7 @@ fn_filename_completion_function(const ch
return NULL;
}
dirname = nptr;
- (void)strlcpy(dirname, text, len);
+ (void)strlcpy(dirname, text, len + 1);
} else {
el_free(filename);
if (*text == 0)
@@ -507,7 +507,7 @@ completion_matches(const char *text, cha
el_free(match_list);
return NULL;
}
- (void)strlcpy(retstr, match_list[1], max_equal);
+ (void)strlcpy(retstr, match_list[1], max_equal + 1);
match_list[0] = retstr;
/* add NULL as last pointer to the array */
Index: src/lib/libedit/readline.c
diff -u src/lib/libedit/readline.c:1.158 src/lib/libedit/readline.c:1.159
--- src/lib/libedit/readline.c:1.158 Tue Oct 8 15:17:57 2019
+++ src/lib/libedit/readline.c Wed Oct 9 10:31:07 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: readline.c,v 1.158 2019/10/08 19:17:57 christos Exp $ */
+/* $NetBSD: readline.c,v 1.159 2019/10/09 14:31:07 christos Exp $ */
/*-
* Copyright (c) 1997 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
#include "config.h"
#if !defined(lint) && !defined(SCCSID)
-__RCSID("$NetBSD: readline.c,v 1.158 2019/10/08 19:17:57 christos Exp $");
+__RCSID("$NetBSD: readline.c,v 1.159 2019/10/09 14:31:07 christos Exp $");
#endif /* not lint && not SCCSID */
#include <sys/types.h>
@@ -607,7 +607,7 @@ get_history_event(const char *cmd, int *
else {
if ((pat = el_calloc(len + 1, sizeof(*pat))) == NULL)
return NULL;
- (void)strlcpy(pat, cmd + begin, len);
+ (void)strlcpy(pat, cmd + begin, len + 1);
}
if (history(h, &ev, H_CURR) != 0) {
@@ -701,7 +701,7 @@ _history_expand_command(const char *comm
if ((aptr = el_calloc(offs + 1, sizeof(*aptr)))
== NULL)
return -1;
- strlcpy(aptr, command, offs);
+ (void)strlcpy(aptr, command, offs + 1);
idx = 1;
} else {
int qchar;
@@ -958,7 +958,7 @@ history_expand(char *str, char **output)
} \
result = nresult; \
} \
- (void)strlcpy(&result[idx], what, len); \
+ (void)strlcpy(&result[idx], what, len + 1); \
idx += len; \
}
@@ -1147,7 +1147,7 @@ history_tokenize(const char *str)
el_free(result);
return NULL;
}
- (void)strlcpy(temp, &str[start], len);
+ (void)strlcpy(temp, &str[start], len + 1);
result[idx++] = temp;
result[idx] = NULL;
if (str[i])