[PATCH 1/3] make_absolute_path: return the input path if it points to our buffer

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

 



Some codepaths call make_absolute_path with its own return value as
input. In such a cases, return the path immediately.

This fixes a valgrind-discovered error, whereby we tried to copy a
string onto itself.

Signed-off-by: Carlos MartÃn Nieto <cmn@xxxxxxxx>
---
 abspath.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/abspath.c b/abspath.c
index 91ca00f..ff14068 100644
--- a/abspath.c
+++ b/abspath.c
@@ -24,6 +24,10 @@ const char *make_absolute_path(const char *path)
 	char *last_elem = NULL;
 	struct stat st;
 
+	/* We've already done it */
+	if (path == buf || path == next_buf)
+		return path;
+
 	if (strlcpy(buf, path, PATH_MAX) >= PATH_MAX)
 		die ("Too long path: %.*s", 60, path);
 
-- 
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]