[libvirt] [PATCH 01/11] qemu: process: report useful error if alias formatting fails

Peter Krempa pkrempa at redhat.com
Wed Nov 19 10:23:14 UTC 2014


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 | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index 7518138..e58a46d 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -1878,8 +1878,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) {
-- 
2.1.0




More information about the libvir-list mailing list