summaryrefslogtreecommitdiffstats
path: root/fish/tilde.c
diff options
context:
space:
mode:
authorRichard W.M. Jones <rjones@redhat.com>2011-01-04 16:02:48 +0000
committerRichard W.M. Jones <rjones@redhat.com>2011-01-10 09:41:35 +0000
commit8fd6edf2e628dd382fd8e80aada25338981584f5 (patch)
tree09e4725219da30481570efdff4afce227999226e /fish/tilde.c
parentfebf614d7e3ac47ceed9a556d8ca8ca2ed23a563 (diff)
downloadlibguestfs-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.c2
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");