r23784: use the GPLv3 boilerplate as recommended by the FSF and the license text
[vlendec/samba-autobuild/.git] / source3 / libsmb / spnego.c
index 50caf7b4c0e9d09b6016e45c25218f58b0cd5b02..d69d25c0dbac867226102d39f72b8bf5cd2fc52e 100644 (file)
@@ -7,7 +7,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,
@@ -17,8 +17,7 @@
 
    
    You should have received a copy of the GNU General Public License
-   along with this program; if not, write to the Free Software
-   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
 
 #include "includes.h"
@@ -42,13 +41,18 @@ static BOOL read_negTokenInit(ASN1_DATA *asn1, negTokenInit_t *token)
                        asn1_start_tag(asn1, ASN1_CONTEXT(0));
                        asn1_start_tag(asn1, ASN1_SEQUENCE(0));
 
-                       token->mechTypes = malloc(sizeof(*token->mechTypes));
+                       token->mechTypes = SMB_MALLOC_P(const char *);
                        for (i = 0; !asn1->has_error &&
                                     0 < asn1_tag_remaining(asn1); i++) {
+                               char *p_oid = NULL;
                                token->mechTypes = 
-                                       realloc(token->mechTypes, (i + 2) *
-                                               sizeof(*token->mechTypes));
-                               asn1_read_OID(asn1, token->mechTypes + i);
+                                       SMB_REALLOC_ARRAY(token->mechTypes, const char *, i + 2);
+                               if (!token->mechTypes) {
+                                       asn1->has_error = True;
+                                       return False;
+                               }
+                               asn1_read_OID(asn1, &p_oid);
+                               token->mechTypes[i] = p_oid;
                        }
                        token->mechTypes[i] = NULL;
                        
@@ -318,7 +322,7 @@ BOOL free_spnego_data(SPNEGO_DATA *spnego)
                if (spnego->negTokenInit.mechTypes) {
                        int i;
                        for (i = 0; spnego->negTokenInit.mechTypes[i]; i++) {
-                               free(spnego->negTokenInit.mechTypes[i]);
+                               free(CONST_DISCARD(char *,spnego->negTokenInit.mechTypes[i]));
                        }
                        free(spnego->negTokenInit.mechTypes);
                }
@@ -340,4 +344,3 @@ BOOL free_spnego_data(SPNEGO_DATA *spnego)
 out:
        return ret;
 }
-