diff options
author | Richard W.M. Jones <rjones@redhat.com> | 2011-01-04 16:02:48 +0000 |
---|---|---|
committer | Richard W.M. Jones <rjones@redhat.com> | 2011-01-10 09:41:35 +0000 |
commit | 8fd6edf2e628dd382fd8e80aada25338981584f5 (patch) | |
tree | 09e4725219da30481570efdff4afce227999226e /fish/tilde.c | |
parent | febf614d7e3ac47ceed9a556d8ca8ca2ed23a563 (diff) | |
download | libguestfs-8fd6edf2e628dd382fd8e80aada25338981584f5.tar.gz libguestfs-8fd6edf2e628dd382fd8e80aada25338981584f5.tar.xz libguestfs-8fd6edf2e628dd382fd8e80aada25338981584f5.zip |
fish: Fix off-by-one bug in tilde expansion.
Although this doesn't seem to cause a crash, valgrind confirms
that this is a genuine off-by-one bug. It could potentially
cause a crash if you did:
echo 'echo ~root/foo' | guestfish
(cherry picked from commit a9802509184341e731de5c9af363184a9964a8a7)
Diffstat (limited to 'fish/tilde.c')
-rw-r--r-- | fish/tilde.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/fish/tilde.c b/fish/tilde.c index 83aa70d9..806297c5 100644 --- a/fish/tilde.c +++ b/fish/tilde.c @@ -58,7 +58,7 @@ try_tilde_expansion (char *str) home = find_home_for_username (&str[1], len); if (home) { - len = strlen (home) + strlen (rest); + len = strlen (home) + strlen (rest) + 1; str = malloc (len); if (str == NULL) { perror ("malloc"); |