X-Git-Url: http://git.annexia.org/?p=libguestfs.git;a=blobdiff_plain;f=fish%2Ftilde.c;h=83aa70d9a6708656dfcfabb0869a82bfc47cd561;hp=1c52d3ed2e873cc098e52dd2f061896295dff258;hb=e1aca6323e33e0dd50e23dc0d638f5789c9188e4;hpb=6a14f1c2502f58ff7bed8cb451f95a83f5ee920a diff --git a/fish/tilde.c b/fish/tilde.c index 1c52d3e..83aa70d 100644 --- a/fish/tilde.c +++ b/fish/tilde.c @@ -62,7 +62,7 @@ try_tilde_expansion (char *str) str = malloc (len); if (str == NULL) { perror ("malloc"); - exit (1); + exit (EXIT_FAILURE); } strcpy (str, home); strcat (str, rest); @@ -85,11 +85,11 @@ expand_home (const char *append) home = getenv ("HOME"); if (!home) home = "~"; - len = strlen (home) + (append ? strlen (append) : 0); + len = strlen (home) + (append ? strlen (append) : 0) + 1; str = malloc (len); if (str == NULL) { perror ("malloc"); - exit (1); + exit (EXIT_FAILURE); } strcpy (str, home); @@ -110,7 +110,7 @@ find_home_for_username (const char *username, size_t ulen) setpwent (); while ((pw = getpwent ()) != NULL) { if (strlen (pw->pw_name) == ulen && - strncmp (username, pw->pw_name, ulen) == 0) + STREQLEN (username, pw->pw_name, ulen)) return pw->pw_dir; }