X-Git-Url: http://git.annexia.org/?p=libguestfs.git;a=blobdiff_plain;f=fish%2Ftilde.c;h=83aa70d9a6708656dfcfabb0869a82bfc47cd561;hp=4085417817d3b9ba14698d13134d6e24663d42d9;hb=b52183b5491748d9e979d30e55db6d648b102416;hpb=05fd2a60466cb7c270b60e9b93c46548acf319cd diff --git a/fish/tilde.c b/fish/tilde.c index 4085417..83aa70d 100644 --- a/fish/tilde.c +++ b/fish/tilde.c @@ -22,7 +22,6 @@ #include #include #include -#include #include #include #include @@ -63,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); @@ -86,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); @@ -111,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; }