ntquotas: support "freeing" an empty quota list
authorUri Simchoni <uri@samba.org>
Sun, 18 Sep 2016 08:09:54 +0000 (11:09 +0300)
committerJeremy Allison <jra@samba.org>
Tue, 4 Oct 2016 00:00:22 +0000 (02:00 +0200)
This avoids dereferencing a null pointer if there's
an attempt to free an empty list.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=12307

Signed-off-by: Uri Simchoni <uri@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source3/libsmb/cliquota.c
source3/smbd/ntquotas.c

index 778fefcd8658321686bab3dcaf82385b246efddc..a2c6edd5f9512f36cfc33f37bc88e957c4aa0f68 100644 (file)
@@ -34,8 +34,9 @@ NTSTATUS cli_get_quota_handle(struct cli_state *cli, uint16_t *quota_fnum)
 
 void free_ntquota_list(SMB_NTQUOTA_LIST **qt_list)
 {
-       if (!qt_list)
+       if (!qt_list || !*qt_list) {
                return;
+       }
 
        if ((*qt_list)->mem_ctx)
                talloc_destroy((*qt_list)->mem_ctx);
index 9b2e39a72bf8e1e0d702f693202fcd5268388fb9..93f4a2ae12fe905cd886ffdb4480d6ef072648e9 100644 (file)
@@ -231,8 +231,7 @@ int vfs_get_user_ntquota_list(files_struct *fsp, SMB_NTQUOTA_LIST **qt_list)
 
 static int quota_handle_destructor(SMB_NTQUOTA_HANDLE *handle)
 {
-       if (handle->quota_list)
-               free_ntquota_list(&handle->quota_list);
+       free_ntquota_list(&handle->quota_list);
        return 0;
 }