mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 13:45:38 +00:00
xenconfig: check return value of regcomp
Commit ec63000a
missed checking the return value of regcomp(),
which coverity promptly identified.
This commit is contained in:
parent
50078cfbcb
commit
71daae9671
@ -325,6 +325,7 @@ xenParseSxprVifRate(const char *rate, unsigned long long *kbytes_per_sec)
|
|||||||
char *trate = NULL;
|
char *trate = NULL;
|
||||||
char *p;
|
char *p;
|
||||||
regex_t rec;
|
regex_t rec;
|
||||||
|
int err;
|
||||||
char *suffix;
|
char *suffix;
|
||||||
unsigned long long tmp;
|
unsigned long long tmp;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
@ -336,7 +337,16 @@ xenParseSxprVifRate(const char *rate, unsigned long long *kbytes_per_sec)
|
|||||||
if (p != NULL)
|
if (p != NULL)
|
||||||
*p = 0;
|
*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)) {
|
if (regexec(&rec, trate, 0, NULL, 0)) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("Invalid rate '%s' specified"), rate);
|
_("Invalid rate '%s' specified"), rate);
|
||||||
|
Loading…
Reference in New Issue
Block a user