[PATCH 1/3] make_absolute_path: Don't try to copy a string to itself

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Sometimes (at least in t-0001-init.sh test 12), the return value of
make_absolute_path() is passed to it as an argument, making the first
and second arguments to strlcpy() the same, making the test fail when
run under valgrind.

Signed-off-by: Carlos MartÃn Nieto <cmn@xxxxxxxx>
---

This patch assumes the path returned by make_absolute_path() is never
longer than PATH_MAX, which I think is a safe assumption.

 abspath.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/abspath.c b/abspath.c
index 91ca00f..9149a98 100644
--- a/abspath.c
+++ b/abspath.c
@@ -24,7 +24,7 @@ const char *make_absolute_path(const char *path)
 	char *last_elem = NULL;
 	struct stat st;
 
-	if (strlcpy(buf, path, PATH_MAX) >= PATH_MAX)
+	if (buf != path && strlcpy(buf, path, PATH_MAX) >= PATH_MAX)
 		die ("Too long path: %.*s", 60, path);
 
 	while (depth--) {
-- 
1.7.4.1

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]