mirror of
https://github.com/libguestfs/libguestfs.git
synced 2026-03-22 07:03:38 +00:00
launch: move the filename checking to a wrapper
Move the filename's comma character checking to a wrapper.
Signed-off-by: Wanlong Gao <gaowanlong@cn.fujitsu.com>
(cherry picked from commit e0c3093795)
This commit is contained in:
committed by
Richard W.M. Jones
parent
ae41a59717
commit
13a7415595
18
src/launch.c
18
src/launch.c
@@ -277,6 +277,16 @@ valid_format_iface (const char *str)
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int
|
||||
check_path (guestfs_h *g, const char *filename)
|
||||
{
|
||||
if (strchr (filename, ',') != NULL) {
|
||||
error (g, _("filename cannot contain ',' (comma) character"));
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
guestfs__add_drive_opts (guestfs_h *g, const char *filename,
|
||||
const struct guestfs_add_drive_opts_argv *optargs)
|
||||
@@ -287,10 +297,8 @@ guestfs__add_drive_opts (guestfs_h *g, const char *filename,
|
||||
char *name;
|
||||
int use_cache_off;
|
||||
|
||||
if (strchr (filename, ',') != NULL) {
|
||||
error (g, _("filename cannot contain ',' (comma) character"));
|
||||
if (check_path(g, filename) == -1)
|
||||
return -1;
|
||||
}
|
||||
|
||||
readonly = optargs->bitmask & GUESTFS_ADD_DRIVE_OPTS_READONLY_BITMASK
|
||||
? optargs->readonly : 0;
|
||||
@@ -398,10 +406,8 @@ guestfs__add_drive_ro_with_if (guestfs_h *g, const char *filename,
|
||||
int
|
||||
guestfs__add_cdrom (guestfs_h *g, const char *filename)
|
||||
{
|
||||
if (strchr (filename, ',') != NULL) {
|
||||
error (g, _("filename cannot contain ',' (comma) character"));
|
||||
if (check_path(g, filename) == -1)
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (access (filename, F_OK) == -1) {
|
||||
perrorf (g, "%s", filename);
|
||||
|
||||
Reference in New Issue
Block a user