diff options
author | Jim Meyering <jim@meyering.net> | 2003-04-10 16:47:35 +0000 |
---|---|---|
committer | Jim Meyering <jim@meyering.net> | 2003-04-10 16:47:35 +0000 |
commit | ef6c0046482844db49d7b2e0729f6c98f37efae4 (patch) | |
tree | 8be3bbc2868ec7869d60a004b2fe55ef2ac19ec0 | |
parent | 6a5f07163fb79b77e8d8ef636fbf6fd714811691 (diff) | |
download | coreutils-ef6c0046482844db49d7b2e0729f6c98f37efae4.tar.xz |
(canonicalize_file_name): Return NULL immediately if resolvepath fails.
Otherwise, `readlink --canonical /no-such-file' would exhaust
virtual memory on some systems (e.g. Solaris).
-rw-r--r-- | lib/canonicalize.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/lib/canonicalize.c b/lib/canonicalize.c index 66622817b..e82ae75ad 100644 --- a/lib/canonicalize.c +++ b/lib/canonicalize.c @@ -147,6 +147,11 @@ canonicalize_file_name (const char *name) resolved_size = 2 * resolved_size + 1; resolved = xmalloc (resolved_size); resolved_len = resolvepath (name, resolved, resolved_size); + if (resolved_len < 0) + { + free (resolved); + return NULL; + } if (resolved_len < resolved_size) break; free (resolved); |