Browse Source

remove smb_buffer_alloca

You can't have a function returning a buffer that is allocated with alloca.

This fixes a regression introduced by aad86d023f050751972532c0d8ab6f00f6569451
Thomas Guillem 10 years ago
parent
commit
6932017140
3 changed files with 4 additions and 22 deletions
  1. 0 12
      src/smb_buffer.c
  2. 0 6
      src/smb_buffer.h
  3. 4 4
      src/smb_ntlm.c

+ 0 - 12
src/smb_buffer.c

@@ -54,18 +54,6 @@ int     smb_buffer_alloc(smb_buffer *buf, size_t size)
         return (0);
 }
 
-int     smb_buffer_alloca(smb_buffer *buf, size_t size)
-{
-    assert(buf != NULL);
-
-    buf->data = alloca(size);
-    if (buf->data) {
-        buf->size = size;
-        return (1);
-    } else
-        return (0);
-}
-
 void    smb_buffer_free(smb_buffer *buf)
 {
     if (buf == NULL || buf->data == NULL)

+ 0 - 6
src/smb_buffer.h

@@ -61,12 +61,6 @@ void    smb_buffer_init(smb_buffer *buf, void *data, size_t size);
 int     smb_buffer_alloc(smb_buffer *buf, size_t size);
 
 /**
- * @brief Allocate a size long memory area from the stack and place it in
- *  the buffer structure
- */
-int    smb_buffer_alloca(smb_buffer *buf, size_t size);
-
-/**
  * @brief Free the data of this buffer if necessary
  *
  * @param buf Pointer to a buffer to free

+ 4 - 4
src/smb_ntlm.c

@@ -141,18 +141,18 @@ uint8_t     *smb_ntlm2_response(smb_ntlmh *hash_v2, uint64_t srv_challenge,
     uint8_t         *response, hmac[16];
 
 
-    if (smb_buffer_alloca(&data, sizeof(uint64_t) + blob->size) == 0)
+    if (smb_buffer_alloc(&data, sizeof(uint64_t) + blob->size) == 0)
         return NULL;
     memcpy(data.data, (void *)&srv_challenge, sizeof(uint64_t));
     memcpy(data.data + sizeof(uint64_t), blob->data, blob->size);
 
     HMAC_MD5(hash_v2, SMB_NTLM_HASH_SIZE, data.data, data.size, &hmac);
+    smb_buffer_free(&data);
 
     response = malloc(blob->size + 16);
-    if (!response) {
-        smb_buffer_free(&data);
+    if (!response)
         return NULL;
-    }
+
     memcpy(response, (void *)hmac, 16);
     memcpy(response + 16, blob->data, blob->size);