/* 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
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include <config.h>
#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);
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;