]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu: process: report useful error if alias formatting fails
authorPeter Krempa <pkrempa@redhat.com>
Thu, 13 Nov 2014 19:10:51 +0000 (20:10 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Fri, 21 Nov 2014 10:00:10 +0000 (11:00 +0100)
When retrieving the paths for PTY devices the alias gets formatted into
a static string. If it doesn't fit we wouldn't report an error.

src/qemu/qemu_process.c

index 1f22bd012a86fb2bdecc0f193c17d6497b4ce374..9bf2ed36d2ac624e15f7dabd489eee31644febc0 100644 (file)
@@ -1879,8 +1879,12 @@ qemuProcessLookupPTYs(virDomainDefPtr def,
 
             if (snprintf(id, sizeof(id), "%s%s",
                          chardevfmt ? "char" : "",
-                         chr->info.alias) >= sizeof(id))
+                         chr->info.alias) >= sizeof(id)) {
+                virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+                               _("failed to format device alias "
+                                 "for PTY retrieval"));
                 return -1;
+            }
 
             path = (const char *) virHashLookup(paths, id);
             if (path == NULL) {