X-Git-Url: http://git.annexia.org/?p=libguestfs.git;a=blobdiff_plain;f=daemon%2Fglob.c;h=f2815ecc963364f1c877947a55cb1a7de4251bb7;hp=f39832eabb9e8a666eef2f54a7d4fecf22f33e86;hb=19005b2cfc6b077aafd16cb5b97a08180e4e39f8;hpb=05c34c1c1479bb07b31cfbf912743a8cf014a636 diff --git a/daemon/glob.c b/daemon/glob.c index f39832e..f2815ec 100644 --- a/daemon/glob.c +++ b/daemon/glob.c @@ -1,5 +1,5 @@ /* libguestfs - the guestfsd daemon - * Copyright (C) 2009 Red Hat Inc. + * Copyright (C) 2009 Red Hat Inc. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -26,14 +26,11 @@ #include "actions.h" char ** -do_glob_expand (char *pattern) +do_glob_expand (const char *pattern) { int r; glob_t buf; - NEED_ROOT (NULL); - ABS_PATH (pattern, NULL); /* Required so chroot can be used. */ - /* glob(3) in glibc never calls chdir, so this seems to be safe: */ CHROOT_IN; r = glob (pattern, GLOB_MARK|GLOB_BRACE, NULL, &buf); @@ -43,13 +40,17 @@ do_glob_expand (char *pattern) char **rv; rv = malloc (sizeof (char *) * 1); + if (rv == NULL) { + reply_with_perror ("malloc"); + return NULL; + } rv[0] = NULL; return rv; /* Caller frees. */ } if (r != 0) { if (errno != 0) - reply_with_perror ("glob: %s", pattern); + reply_with_perror ("%s", pattern); else reply_with_error ("glob failed: %s", pattern); return NULL;