[PATCH] xenconfig: check return value of regcomp

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Commit ec63000a missed checking the return value of regcomp(),
which coverity promptly identified.

Signed-off-by: Jim Fehlig <jfehlig@xxxxxxxx>
---
 src/xenconfig/xen_sxpr.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/src/xenconfig/xen_sxpr.c b/src/xenconfig/xen_sxpr.c
index a7a622f..cd6f207 100644
--- a/src/xenconfig/xen_sxpr.c
+++ b/src/xenconfig/xen_sxpr.c
@@ -325,6 +325,7 @@ xenParseSxprVifRate(const char *rate, unsigned long long *kbytes_per_sec)
     char *trate = NULL;
     char *p;
     regex_t rec;
+    int err;
     char *suffix;
     unsigned long long tmp;
     int ret = -1;
@@ -336,7 +337,16 @@ xenParseSxprVifRate(const char *rate, unsigned long long *kbytes_per_sec)
     if (p != NULL)
         *p = 0;
 
-    regcomp(&rec, vif_bytes_per_sec_re, REG_EXTENDED|REG_NOSUB);
+    err = regcomp(&rec, vif_bytes_per_sec_re, REG_EXTENDED|REG_NOSUB);
+    if (err != 0) {
+        char error[100];
+        regerror(err, &rec, error, sizeof(error));
+        virReportError(VIR_ERR_INTERNAL_ERROR,
+                       _("Failed to compile regular expression '%s': %s"),
+                       vif_bytes_per_sec_re, error);
+        goto cleanup;
+    }
+
     if (regexec(&rec, trate, 0, NULL, 0)) {
         virReportError(VIR_ERR_INTERNAL_ERROR,
                        _("Invalid rate '%s' specified"), rate);
-- 
2.6.1

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]