mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-23 06:05:27 +00:00
qemu: Use virStrcpy in qemuNodeGetSecurityModel()
The code we have there to copy seclabel model or doi can be replaced by virStrcpy() calls which do exactly the same checks. Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
7f93905e45
commit
4aff353dd5
@ -5930,7 +5930,6 @@ static int qemuNodeGetSecurityModel(virConnectPtr conn,
|
|||||||
virSecurityModelPtr secmodel)
|
virSecurityModelPtr secmodel)
|
||||||
{
|
{
|
||||||
virQEMUDriverPtr driver = conn->privateData;
|
virQEMUDriverPtr driver = conn->privateData;
|
||||||
char *p;
|
|
||||||
g_autoptr(virCaps) caps = NULL;
|
g_autoptr(virCaps) caps = NULL;
|
||||||
|
|
||||||
memset(secmodel, 0, sizeof(*secmodel));
|
memset(secmodel, 0, sizeof(*secmodel));
|
||||||
@ -5946,23 +5945,21 @@ static int qemuNodeGetSecurityModel(virConnectPtr conn,
|
|||||||
caps->host.secModels[0].model == NULL)
|
caps->host.secModels[0].model == NULL)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
p = caps->host.secModels[0].model;
|
if (virStrcpy(secmodel->model, caps->host.secModels[0].model,
|
||||||
if (strlen(p) >= VIR_SECURITY_MODEL_BUFLEN-1) {
|
VIR_SECURITY_MODEL_BUFLEN) < 0) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("security model string exceeds max %d bytes"),
|
_("security model string exceeds max %d bytes"),
|
||||||
VIR_SECURITY_MODEL_BUFLEN-1);
|
VIR_SECURITY_MODEL_BUFLEN - 1);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
strcpy(secmodel->model, p);
|
|
||||||
|
|
||||||
p = caps->host.secModels[0].doi;
|
if (virStrcpy(secmodel->doi, caps->host.secModels[0].doi,
|
||||||
if (strlen(p) >= VIR_SECURITY_DOI_BUFLEN-1) {
|
VIR_SECURITY_DOI_BUFLEN) < 0) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("security DOI string exceeds max %d bytes"),
|
_("security DOI string exceeds max %d bytes"),
|
||||||
VIR_SECURITY_DOI_BUFLEN-1);
|
VIR_SECURITY_DOI_BUFLEN - 1);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
strcpy(secmodel->doi, p);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user