s3-client Add TALLOC_CTX argument to attrib_string().
authorAndrew Bartlett <abartlet@samba.org>
Fri, 29 Apr 2011 02:05:07 +0000 (12:05 +1000)
committerAndrew Bartlett <abartlet@samba.org>
Fri, 29 Apr 2011 06:38:14 +0000 (16:38 +1000)
This ensures the caller knows where the memory was allocated.

Andrew Bartlett

source3/client/client.c
source3/include/proto.h
source3/lib/util.c

index 4c90716c48b8ebfb7ca72f94dac7fc2f61e14e1e..c734a24a6cb6d2c90a82127cb8d9f11e323fe800 100644 (file)
@@ -547,7 +547,7 @@ static NTSTATUS display_finfo(struct cli_state *cli_state, struct file_info *fin
        if (!showacls) {
                d_printf("  %-30s%7.7s %8.0f  %s",
                         finfo->name,
-                        attrib_string(finfo->mode),
+                        attrib_string(talloc_tos(), finfo->mode),
                        (double)finfo->size,
                        time_to_asc(t));
                dir_total += finfo->size;
@@ -569,7 +569,7 @@ static NTSTATUS display_finfo(struct cli_state *cli_state, struct file_info *fin
                }
                /* print file meta date header */
                d_printf( "FILENAME:%s\n", finfo->name);
-               d_printf( "MODE:%s\n", attrib_string(finfo->mode));
+               d_printf( "MODE:%s\n", attrib_string(talloc_tos(), finfo->mode));
                d_printf( "SIZE:%.0f\n", (double)finfo->size);
                d_printf( "MTIME:%s", time_to_asc(t));
                status = cli_ntcreate(cli_state, afname, 0,
index 27a8990e20b00afe4954c6e878b28f1cd4652809..a697188abc35318c4075029e61f18d2a2c99045e 100644 (file)
@@ -630,7 +630,7 @@ bool file_exist_stat(const char *fname,SMB_STRUCT_STAT *sbuf,
 bool socket_exist(const char *fname);
 uint64_t get_file_size_stat(const SMB_STRUCT_STAT *sbuf);
 SMB_OFF_T get_file_size(char *file_name);
-char *attrib_string(uint16 mode);
+char *attrib_string(TALLOC_CTX *mem_ctx, uint16 mode);
 void show_msg(char *buf);
 void smb_set_enclen(char *buf,int len,uint16 enc_ctx_num);
 void smb_setlen(char *buf,int len);
index f592a0f778e40b8348c9286ff486ca43fe8cc552..d908ea86f05b69ed485e1ee2db7fa6a7ee4b3025 100644 (file)
@@ -298,7 +298,7 @@ SMB_OFF_T get_file_size(char *file_name)
  Return a string representing an attribute for a file.
 ********************************************************************/
 
-char *attrib_string(uint16 mode)
+char *attrib_string(TALLOC_CTX *mem_ctx, uint16 mode)
 {
        fstring attrstr;
 
@@ -311,7 +311,7 @@ char *attrib_string(uint16 mode)
        if (mode & FILE_ATTRIBUTE_SYSTEM) fstrcat(attrstr,"S");
        if (mode & FILE_ATTRIBUTE_READONLY) fstrcat(attrstr,"R");
 
-       return talloc_strdup(talloc_tos(), attrstr);
+       return talloc_strdup(mem_ctx, attrstr);
 }
 
 /*******************************************************************