Spelling fixes for lib/compression.
[sfrench/samba-autobuild/.git] / source3 / smbd / seal.c
index e9dc46aa3cd6cc133a809592323ff8d2e71e9ff2..700d7ea02e2e3d22be0403202fba276de8f996e9 100644 (file)
@@ -18,6 +18,9 @@
 */
 
 #include "includes.h"
+#include "smbd/globals.h"
+#include "../libcli/auth/spnego.h"
+#include "ntlmssp.h"
 
 /******************************************************************************
  Server side encryption.
@@ -32,9 +35,6 @@ struct smb_srv_trans_enc_ctx {
        AUTH_NTLMSSP_STATE *auth_ntlmssp_state; /* Must be kept in sync with pointer in ec->ntlmssp_state. */
 };
 
-static struct smb_srv_trans_enc_ctx *partial_srv_trans_enc_ctx;
-static struct smb_srv_trans_enc_ctx *srv_trans_enc_ctx;
-
 /******************************************************************************
  Return global enc context - this must change if we ever do multiple contexts.
 ******************************************************************************/
@@ -128,8 +128,7 @@ static NTSTATUS get_srv_gss_creds(const char *service,
        gss_OID_desc nt_hostbased_service =
        {10, CONST_DISCARD(char *,"\x2a\x86\x48\x86\xf7\x12\x01\x02\x01\x04")};
 
-       asprintf(&host_princ_s, "%s@%s", service, name);
-       if (host_princ_s == NULL) {
+       if (asprintf(&host_princ_s, "%s@%s", service, name) == -1) {
                return NT_STATUS_NO_MEMORY;
        }
 
@@ -426,9 +425,14 @@ static NTSTATUS srv_enc_spnego_gss_negotiate(unsigned char **ppdata, size_t *p_d
        data_blob_free(&auth_reply);
 
        SAFE_FREE(*ppdata);
-       *ppdata = response.data;
+       *ppdata = (unsigned char *)memdup(response.data, response.length);
+       if ((*ppdata) == NULL && response.length > 0) {
+               status = NT_STATUS_NO_MEMORY;
+       }
        *p_data_size = response.length;
 
+       data_blob_free(&response);
+
        return status;
 }
 #endif
@@ -463,8 +467,13 @@ static NTSTATUS srv_enc_ntlm_negotiate(unsigned char **ppdata, size_t *p_data_si
        }
 
        SAFE_FREE(*ppdata);
-       *ppdata = response.data;
+       *ppdata = (unsigned char *)memdup(response.data, response.length);
+       if ((*ppdata) == NULL && response.length > 0) {
+               status = NT_STATUS_NO_MEMORY;
+       }
        *p_data_size = response.length;
+       data_blob_free(&response);
+
        return status;
 }
 
@@ -585,8 +594,11 @@ static NTSTATUS srv_enc_spnego_ntlm_auth(connection_struct *conn,
        }
 
        SAFE_FREE(*ppdata);
-       *ppdata = response.data;
+       *ppdata = (unsigned char *)memdup(response.data, response.length);
+       if ((*ppdata) == NULL && response.length > 0)
+               return NT_STATUS_NO_MEMORY;
        *p_data_size = response.length;
+       data_blob_free(&response);
        return status;
 }
 
@@ -636,8 +648,11 @@ static NTSTATUS srv_enc_raw_ntlm_auth(connection_struct *conn,
 
        /* Return the raw blob. */
        SAFE_FREE(*ppdata);
-       *ppdata = response.data;
+       *ppdata = (unsigned char *)memdup(response.data, response.length);
+       if ((*ppdata) == NULL && response.length > 0)
+               return NT_STATUS_NO_MEMORY;
        *p_data_size = response.length;
+       data_blob_free(&response);
        return status;
 }