qemu: avoid null dereference on failed migration

* src/qemu/qemu_monitor_text.c: qemuMonitorTextGetMigrationStatus: Check for
  failed strchr, to silence a coverity warning.
This commit is contained in:
Eric Blake 2010-03-01 15:34:33 +01:00 committed by Daniel Veillard
parent b769339295
commit bef10f9a05

View File

@ -989,6 +989,11 @@ int qemuMonitorTextGetMigrationStatus(qemuMonitorPtr mon,
if ((tmp = strstr(reply, MIGRATION_PREFIX)) != NULL) {
tmp += strlen(MIGRATION_PREFIX);
end = strchr(tmp, '\r');
if (end == NULL) {
qemuReportError(VIR_ERR_INTERNAL_ERROR,
_("unexpected migration status in %s"), reply);
goto cleanup;
}
*end = '\0';
if ((*status = qemuMonitorMigrationStatusTypeFromString(tmp)) < 0) {