[libvirt] [PATCH] conf: Fix possible NULL dereference in virStorageVolTargetDefFormat

2014-07-11 Thread Matthias Bolte
Commit dae1568c6c6455091e8cd9bc2e90a22af3d3880c converted the perms
member of the virStorageVolTarget struct into a pointer to make it
optional. But virStorageVolTargetDefFormat did not check perms for
NULL before dereferencing it.
---
 src/conf/storage_conf.c | 26 ++
 1 file changed, 14 insertions(+), 12 deletions(-)

diff --git a/src/conf/storage_conf.c b/src/conf/storage_conf.c
index 9ac5975..aa29658 100644
--- a/src/conf/storage_conf.c
+++ b/src/conf/storage_conf.c
@@ -1423,22 +1423,24 @@ virStorageVolTargetDefFormat(virStorageVolOptionsPtr 
options,
 virBufferAsprintf(buf, format type='%s'/\n, format);
 }
 
-virBufferAddLit(buf, permissions\n);
-virBufferAdjustIndent(buf, 2);
+if (def-perms) {
+virBufferAddLit(buf, permissions\n);
+virBufferAdjustIndent(buf, 2);
 
-virBufferAsprintf(buf, mode0%o/mode\n,
-  def-perms-mode);
-virBufferAsprintf(buf, owner%u/owner\n,
-  (unsigned int) def-perms-uid);
-virBufferAsprintf(buf, group%u/group\n,
-  (unsigned int) def-perms-gid);
+virBufferAsprintf(buf, mode0%o/mode\n,
+  def-perms-mode);
+virBufferAsprintf(buf, owner%u/owner\n,
+  (unsigned int) def-perms-uid);
+virBufferAsprintf(buf, group%u/group\n,
+  (unsigned int) def-perms-gid);
 
 
-virBufferEscapeString(buf, label%s/label\n,
-  def-perms-label);
+virBufferEscapeString(buf, label%s/label\n,
+  def-perms-label);
 
-virBufferAdjustIndent(buf, -2);
-virBufferAddLit(buf, /permissions\n);
+virBufferAdjustIndent(buf, -2);
+virBufferAddLit(buf, /permissions\n);
+}
 
 if (def-timestamps) {
 virBufferAddLit(buf, timestamps\n);
-- 
1.9.1

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] [PATCH] conf: Fix possible NULL dereference in virStorageVolTargetDefFormat

2014-07-11 Thread Eric Blake
On 07/11/2014 10:13 AM, Matthias Bolte wrote:
 Commit dae1568c6c6455091e8cd9bc2e90a22af3d3880c converted the perms
 member of the virStorageVolTarget struct into a pointer to make it
 optional. But virStorageVolTargetDefFormat did not check perms for
 NULL before dereferencing it.
 ---
  src/conf/storage_conf.c | 26 ++
  1 file changed, 14 insertions(+), 12 deletions(-)

ACK.

-- 
Eric Blake   eblake redhat com+1-919-301-3266
Libvirt virtualization library http://libvirt.org



signature.asc
Description: OpenPGP digital signature
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Re: [libvirt] [PATCH] conf: Fix possible NULL dereference in virStorageVolTargetDefFormat

2014-07-11 Thread Eric Blake
On 07/11/2014 11:00 AM, Eric Blake wrote:
 On 07/11/2014 10:13 AM, Matthias Bolte wrote:
 Commit dae1568c6c6455091e8cd9bc2e90a22af3d3880c converted the perms
 member of the virStorageVolTarget struct into a pointer to make it
 optional. But virStorageVolTargetDefFormat did not check perms for
 NULL before dereferencing it.
 ---
  src/conf/storage_conf.c | 26 ++
  1 file changed, 14 insertions(+), 12 deletions(-)
 
 ACK.
 

Now pushed.

-- 
Eric Blake   eblake redhat com+1-919-301-3266
Libvirt virtualization library http://libvirt.org



signature.asc
Description: OpenPGP digital signature
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list