summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 25fe217)
raw | patch | inline | side by side (parent: 25fe217)
author | Johannes Sixt <johannes.sixt@telecom.at> | |
Fri, 30 Nov 2007 20:36:00 +0000 (21:36 +0100) | ||
committer | Johannes Sixt <johannes.sixt@telecom.at> | |
Mon, 23 Jun 2008 11:30:27 +0000 (13:30 +0200) |
In this function we must be careful to handle drive-local paths else there
is a danger that it runs into an infinite loop.
Signed-off-by: Johannes Sixt <johannes.sixt@telecom.at>
is a danger that it runs into an infinite loop.
Signed-off-by: Johannes Sixt <johannes.sixt@telecom.at>
sha1_file.c | patch | blob | history |
diff --git a/sha1_file.c b/sha1_file.c
index 6f004ffd09ac91912e2c84cdede2b6e7e3122b2b..0a54eed761f6836d48eb28dd160e94a779a4bfba 100644 (file)
--- a/sha1_file.c
+++ b/sha1_file.c
return 0;
}
+static inline int offset_1st_component(const char *path)
+{
+ if (has_dos_drive_prefix(path))
+ return 2 + (path[2] == '/');
+ return *path == '/';
+}
+
int safe_create_leading_directories(char *path)
{
- char *pos = path;
+ char *pos = path + offset_1st_component(path);
struct stat st;
- if (is_absolute_path(path))
- pos++;
-
while (pos) {
pos = strchr(pos, '/');
if (!pos)