From 108f83ece979cf867a75faf321cd9d6dacc490b4 Mon Sep 17 00:00:00 2001 From: "Thomas E. Dickey" Date: Tue, 31 Jul 2007 20:57:23 -0400 Subject: snapshot of project "lynx", label v2-8-7dev_5e --- src/LYUtils.c | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) (limited to 'src/LYUtils.c') diff --git a/src/LYUtils.c b/src/LYUtils.c index 18199133..cd5423d8 100644 --- a/src/LYUtils.c +++ b/src/LYUtils.c @@ -1,4 +1,4 @@ -/* $LynxId: LYUtils.c,v 1.161 2007/07/22 23:53:16 tom Exp $ */ +/* $LynxId: LYUtils.c,v 1.162 2007/07/31 00:45:03 tom Exp $ */ #include #include #include @@ -5884,15 +5884,31 @@ static BOOL IsOurSymlink(const char *name) char *buffer = typeMallocn(char, size); if (buffer != 0) { - while ((used = readlink(name, buffer, size)) == -1) { + while ((used = readlink(name, buffer, size - 1)) == size - 1) { buffer = typeRealloc(char, buffer, size *= 2); if (buffer == 0) break; } - buffer[used] = '\0'; + if (used > 0) { + buffer[used] = '\0'; + } else { + FREE(buffer); + } } if (buffer != 0) { + if (!LYisAbsPath(buffer)) { + char *cutoff = LYLastPathSep(name); + char *clone = NULL; + + if (cutoff != 0) { + HTSprintf0(&clone, "%.*s%s%s", + cutoff - name, + name, PATHSEP_STR, buffer); + FREE(buffer); + buffer = clone; + } + } CTRACE2(TRACE_CFG, (tfp, "IsOurSymlink(%s -> %s)\n", name, buffer)); result = IsOurFile(buffer); FREE(buffer); -- cgit 1.4.1-2-gfad0