[libvirt] [PATCH] util: fixing wrong comparison inside virStoragePermsCopy().

Julio Faracco posted 1 patch 6 years, 10 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/1496368686-15087-1-git-send-email-jcfaracco@gmail.com
src/util/virstoragefile.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[libvirt] [PATCH] util: fixing wrong comparison inside virStoragePermsCopy().
Posted by Julio Faracco 6 years, 10 months ago
VIR_STRDUP returns -1 if the string copy was not successful. So, the current
comparison/logic is throwing an error when VIR_STRDUP() returns 1. Only when
source is NULL, it is considering as a success which is not right.

Signed-off-by: Julio Faracco <jcfaracco@gmail.com>
---
 src/util/virstoragefile.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c
index 6d8ada9..e82a7fb 100644
--- a/src/util/virstoragefile.c
+++ b/src/util/virstoragefile.c
@@ -1974,7 +1974,7 @@ virStoragePermsCopy(const virStoragePerms *src)
     ret->uid = src->uid;
     ret->gid = src->gid;
 
-    if (VIR_STRDUP(ret->label, src->label))
+    if (VIR_STRDUP(ret->label, src->label) < 0)
         goto error;
 
     return ret;
-- 
2.7.4

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] util: fixing wrong comparison inside virStoragePermsCopy().
Posted by Peter Krempa 6 years, 10 months ago
On Thu, Jun 01, 2017 at 22:58:06 -0300, Julio Faracco wrote:
> VIR_STRDUP returns -1 if the string copy was not successful. So, the current
> comparison/logic is throwing an error when VIR_STRDUP() returns 1. Only when
> source is NULL, it is considering as a success which is not right.
> 
> Signed-off-by: Julio Faracco <jcfaracco@gmail.com>
> ---
>  src/util/virstoragefile.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

ACK, I'll rewrap the commit message and push this shortly.
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list