diff options
author | Thomas E. Dickey <dickey@invisible-island.net> | 2007-07-31 20:57:23 -0400 |
---|---|---|
committer | Thomas E. Dickey <dickey@invisible-island.net> | 2007-07-31 20:57:23 -0400 |
commit | 108f83ece979cf867a75faf321cd9d6dacc490b4 (patch) | |
tree | dd4970a2e7923be3fa49f5213507791087296bd2 /src/LYUtils.c | |
parent | f280565bc0561b7151fae26b4a3a9f07f9c923f5 (diff) | |
download | lynx-snapshots-108f83ece979cf867a75faf321cd9d6dacc490b4.tar.gz |
snapshot of project "lynx", label v2-8-7dev_5e
Diffstat (limited to 'src/LYUtils.c')
-rw-r--r-- | src/LYUtils.c | 22 |
1 files changed, 19 insertions, 3 deletions
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 <HTUtils.h> #include <HTTCP.h> #include <HTParse.h> @@ -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); |