X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=qemu-io-cmds.c;h=883f53b64d3cf79998fae66f822568c915e0278b;hb=0c1bd4692f9a19fb4d4bb3afe45439a09c37ab4c;hp=2c48f9ce1a6d81f8f992f8c942e52253dafae45e;hpb=ff79d5e939c38677a575e3493eb9b4d36eb21865;p=mirror_qemu.git diff --git a/qemu-io-cmds.c b/qemu-io-cmds.c index 2c48f9ce1a..883f53b64d 100644 --- a/qemu-io-cmds.c +++ b/qemu-io-cmds.c @@ -35,6 +35,13 @@ static int compare_cmdname(const void *a, const void *b) void qemuio_add_command(const cmdinfo_t *ci) { + /* ci->perm assumes a file is open, but the GLOBAL and NOFILE_OK + * flags allow it not to be, so that combination is invalid. + * Catch it now rather than letting it manifest as a crash if a + * particular set of command line options are used. + */ + assert(ci->perm == 0 || + (ci->flags & (CMD_FLAG_GLOBAL | CMD_NOFILE_OK)) == 0); cmdtab = g_renew(cmdinfo_t, cmdtab, ++ncmds); cmdtab[ncmds - 1] = *ci; qsort(cmdtab, ncmds, sizeof(*cmdtab), compare_cmdname);