]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
smbd: Move two SMB1-only functions to smb1_utils.c
authorVolker Lendecke <vl@samba.org>
Wed, 1 Jul 2026 15:39:59 +0000 (17:39 +0200)
committerAnoop C S <anoopcs@samba.org>
Fri, 3 Jul 2026 04:47:29 +0000 (04:47 +0000)
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
source3/lib/util.c
source3/smbd/smb1_utils.c
source3/smbd/smb1_utils.h

index 73b9e4d50f99ed868bb4496573dad6346196daa6..06273b4a4279eb1c65b51fc578e258f873e142fa 100644 (file)
@@ -191,50 +191,6 @@ void show_msg(const char *buf)
        TALLOC_FREE(msg);
 }
 
-/*******************************************************************
- Setup only the byte count for a smb message.
-********************************************************************/
-
-int set_message_bcc(char *buf,int num_bytes)
-{
-       int num_words = CVAL(buf,smb_wct);
-       SSVAL(buf,smb_vwv + num_words*SIZEOFWORD,num_bytes);
-       _smb_setlen(buf,smb_size + num_words*2 + num_bytes - 4);
-       return (smb_size + num_words*2 + num_bytes);
-}
-
-/*******************************************************************
- Add a data blob to the end of a smb_buf, adjusting bcc and smb_len.
- Return the bytes added
-********************************************************************/
-
-ssize_t message_push_blob(uint8_t **outbuf, DATA_BLOB blob)
-{
-       size_t newlen;
-       uint8_t *tmp;
-
-       newlen = smb_len(*outbuf) + 4;
-       if (newlen < 4) {
-               return -1;
-       }
-
-       newlen += blob.length;
-       if (newlen < blob.length) {
-               return -1;
-       }
-
-       tmp = talloc_realloc(NULL, *outbuf, uint8_t, newlen);
-       if (tmp == NULL) {
-               DBG_ERR("talloc failed\n");
-               return -1;
-       }
-       *outbuf = tmp;
-
-       memcpy(tmp + smb_len(tmp) + 4, blob.data, blob.length);
-       set_message_bcc((char *)tmp, smb_buflen(tmp) + blob.length);
-       return blob.length;
-}
-
 /*******************************************************************
  Reduce a file name, removing .. elements.
 ********************************************************************/
index 56153cdd634913813c9e326d43469bf64b628b53..0c75df9e45db2d4cf3a1522e0eff05d880c4b03b 100644 (file)
@@ -345,3 +345,47 @@ files_struct *file_fsp(struct smb_request *req, uint16_t fid)
        fsp->fsp_name->st.cached_dos_attributes = FILE_ATTRIBUTE_INVALID;
        return fsp;
 }
+
+/*******************************************************************
+ Setup only the byte count for a smb message.
+********************************************************************/
+
+int set_message_bcc(char *buf, int num_bytes)
+{
+       int num_words = CVAL(buf, smb_wct);
+       SSVAL(buf, smb_vwv + num_words * SIZEOFWORD, num_bytes);
+       _smb_setlen(buf, smb_size + num_words * 2 + num_bytes - 4);
+       return (smb_size + num_words * 2 + num_bytes);
+}
+
+/*******************************************************************
+ Add a data blob to the end of a smb_buf, adjusting bcc and smb_len.
+ Return the bytes added
+********************************************************************/
+
+ssize_t message_push_blob(uint8_t **outbuf, DATA_BLOB blob)
+{
+       size_t newlen;
+       uint8_t *tmp;
+
+       newlen = smb_len(*outbuf) + 4;
+       if (newlen < 4) {
+               return -1;
+       }
+
+       newlen += blob.length;
+       if (newlen < blob.length) {
+               return -1;
+       }
+
+       tmp = talloc_realloc(NULL, *outbuf, uint8_t, newlen);
+       if (tmp == NULL) {
+               DBG_ERR("talloc failed\n");
+               return -1;
+       }
+       *outbuf = tmp;
+
+       memcpy(tmp + smb_len(tmp) + 4, blob.data, blob.length);
+       set_message_bcc((char *)tmp, smb_buflen(tmp) + blob.length);
+       return blob.length;
+}
index d5eb7a2deed8bd155e7952173c06551f7f9e9740..4e6aadfcb52c46189def141dd3aee4664b992f14 100644 (file)
@@ -43,5 +43,7 @@ NTSTATUS filename_convert_smb1_search_path(TALLOC_CTX *ctx,
                                           struct smb_filename **_smb_fname_out,
                                           char **_mask_out);
 struct files_struct *file_fsp(struct smb_request *req, uint16_t fid);
+int set_message_bcc(char *buf, int num_bytes);
+ssize_t message_push_blob(uint8_t **outbuf, DATA_BLOB blob);
 
 #endif