r23779: Change from v2 or later to v3 or later.
[jra/samba/.git] / source3 / libads / authdata.c
index 71294941a602bdb2ac5fc8dfcfea09cd8e070c45..86e3e9edcf03793c16dbb412f708f0752fa3f67a 100644 (file)
@@ -10,7 +10,7 @@
    
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 2 of the License, or
+   the Free Software Foundation; either version 3 of the License, or
    (at your option) any later version.
    
    This program is distributed in the hope that it will be useful,
@@ -120,10 +120,14 @@ static BOOL pac_io_krb_sid_and_attr_array(const char *desc,
                return False;
 
        if (UNMARSHALLING(ps)) {
-               array->krb_sid_and_attrs = PRS_ALLOC_MEM(ps, KRB_SID_AND_ATTRS, num);
-               if (!array->krb_sid_and_attrs) {
-                       DEBUG(3, ("No memory available\n"));
-                       return False;
+               if (num) {
+                       array->krb_sid_and_attrs = PRS_ALLOC_MEM(ps, KRB_SID_AND_ATTRS, num);
+                       if (!array->krb_sid_and_attrs) {
+                               DEBUG(3, ("No memory available\n"));
+                               return False;
+                       }
+               } else {
+                       array->krb_sid_and_attrs = NULL;
                }
        }
 
@@ -184,10 +188,14 @@ static BOOL pac_io_group_membership_array(const char *desc,
                return False;
 
        if (UNMARSHALLING(ps)) {
-               array->group_membership = PRS_ALLOC_MEM(ps, GROUP_MEMBERSHIP, num);
-               if (!array->group_membership) {
-                       DEBUG(3, ("No memory available\n"));
-                       return False;
+               if (num) {
+                       array->group_membership = PRS_ALLOC_MEM(ps, GROUP_MEMBERSHIP, num);
+                       if (!array->group_membership) {
+                               DEBUG(3, ("No memory available\n"));
+                               return False;
+                       }
+               } else {
+                       array->group_membership = NULL;
                }
        }
 
@@ -443,10 +451,11 @@ static BOOL pac_io_pac_signature_data(const char *desc,
                                      PAC_SIGNATURE_DATA *data, uint32 length,
                                      prs_struct *ps, int depth)
 {
-       uint32 siglen = length - sizeof(uint32);
+       uint32 siglen = 0;
+
        prs_debug(ps, depth, desc, "pac_io_pac_signature_data");
        depth++;
-       
+
        if (data == NULL)
                return False;
 
@@ -455,11 +464,18 @@ static BOOL pac_io_pac_signature_data(const char *desc,
        if (!prs_uint32("type", ps, depth, &data->type))
                return False;
 
+       if ( length > sizeof(uint32) )
+               siglen = length - sizeof(uint32);       
+
        if (UNMARSHALLING(ps) && length) {
-               data->signature.buffer = PRS_ALLOC_MEM(ps, uint8, siglen);
-               if (!data->signature.buffer) {
-                       DEBUG(3, ("No memory available\n"));
-                       return False;
+               if (siglen) {
+                       data->signature.buffer = PRS_ALLOC_MEM(ps, uint8, siglen);
+                       if (!data->signature.buffer) {
+                               DEBUG(3, ("No memory available\n"));
+                               return False;
+                       }
+               } else {
+                       data->signature.buffer = NULL;
                }
        }