/* sanlock doesn't use owner_name for anything, so it's safe to take just
* the first SANLK_NAME_LEN - 1 characters from vm_name */
ignore_value(virStrncpy(opt->owner_name, priv->vm_name,
- SANLK_NAME_LEN - 1, SANLK_NAME_LEN));
+ MIN(strlen(priv->vm_name), SANLK_NAME_LEN - 1),
+ SANLK_NAME_LEN));
if (state && STRNEQ(state, "")) {
if ((rv = sanlock_state_to_args((char *)state,
if (xen_host_cpu_get_all(session, &host_cpu_set)) {
host_cpu = host_cpu_set->contents[0];
xen_host_cpu_get_modelname(session, &modelname, host_cpu);
- if (!virStrncpy(info->model, modelname, LIBVIRT_MODELNAME_LEN - 1, LIBVIRT_MODELNAME_LEN)) {
+ if (!virStrncpy(info->model, modelname,
+ MIN(strlen(modelname), LIBVIRT_MODELNAME_LEN - 1),
+ LIBVIRT_MODELNAME_LEN)) {
virReportOOMError();
xen_host_cpu_set_free(host_cpu_set);
VIR_FREE(modelname);
data++;
if (STRPREFIX(key, "mac=")) {
- int len = nextkey ? (nextkey - data) : sizeof(mac) - 1;
+ int len = nextkey ? (nextkey - data) : strlen(data);
if (virStrncpy(mac, data, len, sizeof(mac)) == NULL) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("MAC address %s too big for destination"),
return NULL;
}
} else if (STRPREFIX(key, "bridge=")) {
- int len = nextkey ? (nextkey - data) : sizeof(bridge) - 1;
+ int len = nextkey ? (nextkey - data) : strlen(data);
if (virStrncpy(bridge, data, len, sizeof(bridge)) == NULL) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Bridge %s too big for destination"),
if (VIR_STRNDUP(script, data, len) < 0)
return NULL;
} else if (STRPREFIX(key, "model=")) {
- int len = nextkey ? (nextkey - data) : sizeof(model) - 1;
+ int len = nextkey ? (nextkey - data) : strlen(data);
if (virStrncpy(model, data, len, sizeof(model)) == NULL) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Model %s too big for destination"),
return NULL;
}
} else if (STRPREFIX(key, "type=")) {
- int len = nextkey ? (nextkey - data) : sizeof(type) - 1;
+ int len = nextkey ? (nextkey - data) : strlen(data);
if (virStrncpy(type, data, len, sizeof(type)) == NULL) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Type %s too big for destination"),
return NULL;
}
} else if (STRPREFIX(key, "vifname=")) {
- int len = nextkey ? (nextkey - data) : sizeof(vifname) - 1;
+ int len = nextkey ? (nextkey - data) : strlen(data);
if (virStrncpy(vifname, data, len, sizeof(vifname)) == NULL) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Vifname %s too big for destination"),
return NULL;
}
} else if (STRPREFIX(key, "ip=")) {
- int len = nextkey ? (nextkey - data) : sizeof(ip) - 1;
+ int len = nextkey ? (nextkey - data) : strlen(data);
if (virStrncpy(ip, data, len, sizeof(ip)) == NULL) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("IP %s too big for destination"), data);
return NULL;
}
} else if (STRPREFIX(key, "rate=")) {
- int len = nextkey ? (nextkey - data) : sizeof(rate) - 1;
+ int len = nextkey ? (nextkey - data) : strlen(data);
if (virStrncpy(rate, data, len, sizeof(rate)) == NULL) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("rate %s too big for destination"), data);
data++;
if (STRPREFIX(key, "type=")) {
- int len = nextkey ? (nextkey - data) : sizeof(type) - 1;
+ int len = nextkey ? (nextkey - data) : strlen(data);
if (virStrncpy(type, data, len, sizeof(type)) == NULL) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("type %s invalid"),
goto skipusbctrl;
}
} else if (STRPREFIX(key, "version=")) {
- int len = nextkey ? (nextkey - data) : sizeof(version) - 1;
+ int len = nextkey ? (nextkey - data) : strlen(data);
if (virStrncpy(version, data, len, sizeof(version)) == NULL) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("version %s invalid"),
if (virStrToLong_i(version, NULL, 16, &usbctrl_version) < 0)
goto skipusbctrl;
} else if (STRPREFIX(key, "ports=")) {
- int len = nextkey ? (nextkey - data) : sizeof(ports) - 1;
+ int len = nextkey ? (nextkey - data) : strlen(data);
if (virStrncpy(ports, data, len, sizeof(ports)) == NULL) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("version %s invalid"),
data++;
if (STRPREFIX(key, "hostbus=")) {
- int len = nextkey ? (nextkey - data) : sizeof(bus) - 1;
+ int len = nextkey ? (nextkey - data) : strlen(data);
if (virStrncpy(bus, data, len, sizeof(bus)) == NULL) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("bus %s too big for destination"),
goto skipusb;
}
} else if (STRPREFIX(key, "hostaddr=")) {
- int len = nextkey ? (nextkey - data) : sizeof(device) - 1;
+ int len = nextkey ? (nextkey - data) : strlen(data);
if (virStrncpy(device, data, len, sizeof(device)) == NULL) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("device %s too big for destination"),
data++;
if (STRPREFIX(key, "connection=")) {
- int len = nextkey ? (nextkey - data) : sizeof(type) - 1;
+ int len = nextkey ? (nextkey - data) : strlen(data);
if (virStrncpy(type, data, len, sizeof(type)) == NULL) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("connection %s too big"), data);