+Thu Jul 19 15:38:44 CEST 2007 Daniel Veillard <veillard@redhat.com>
+
+ * src/xen_internal.c: rewrite of range check in credit scheduler
+ initially suggested by Atsushi SAKAI
+
Wed Jul 18 17:45:08 EST 2007 Daniel P. Berrange <berrange@redhat.com>
* src/qemu_conf.c: Remove double free of XML property upon
virSchedParameterPtr params, int nparams)
{
int i;
+ unsigned int val;
xenUnifiedPrivatePtr priv;
if ((domain == NULL) || (domain->conn == NULL)) {
for (i = 0; i < nparams; i++) {
if (STREQ (params[i].field, str_weight) &&
params[i].type == VIR_DOMAIN_SCHED_FIELD_UINT) {
- op_dom.u.getschedinfo.u.credit.weight = params[i].value.ui;
+ val = params[i].value.ui;
+ if ((val < 1) || (val > USHRT_MAX)) {
+ virXenErrorFunc (VIR_ERR_INVALID_ARG, __FUNCTION__,
+ _("Credit scheduler weight parameter (%d) is out of range (1-65535)"),
+ val);
+ return(-1);
+ }
+ op_dom.u.getschedinfo.u.credit.weight = val;
weight_set = 1;
} else if (STREQ (params[i].field, str_cap) &&
params[i].type == VIR_DOMAIN_SCHED_FIELD_UINT) {
- op_dom.u.getschedinfo.u.credit.cap = params[i].value.ui;
+ val = params[i].value.ui;
+ if (val > USHRT_MAX) {
+ virXenErrorFunc (VIR_ERR_INVALID_ARG, __FUNCTION__,
+ _("Credit scheduler cap parameter (%d) is out of range (0-65535)"),
+ val);
+ return(-1);
+ }
+ op_dom.u.getschedinfo.u.credit.cap = val;
cap_set = 1;
} else {
virXenErrorFunc (VIR_ERR_INVALID_ARG, __FUNCTION__,