summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2009-03-19 12:20:11 +1100
committerAndrew Bartlett <abartlet@samba.org>2009-04-14 12:53:56 +1000
commit3b3e21bd9ba701a97e752205263a7903619541c7 (patch)
tree3f0cdf8e4d5a550a323e73d229083d6329b3f236
parent4786a493f70070dce6de4cbe488c9de1bdbb75ad (diff)
downloadsamba-3b3e21bd9ba701a97e752205263a7903619541c7.tar.gz
samba-3b3e21bd9ba701a97e752205263a7903619541c7.tar.bz2
samba-3b3e21bd9ba701a97e752205263a7903619541c7.zip
Convert Samba3 to use the common lib/util/charset API
This removes calls to push_*_allocate() and pull_*_allocate(), as well as convert_string_allocate, as they are not in the common API To allow transition to a common charcnv in future, provide Samba4-like strupper functions in source3/lib/charcnv.c (the actual implementation remains distinct, but the API is now shared) Andrew Bartlett
-rw-r--r--source3/include/proto.h11
-rw-r--r--source3/lib/charcnv.c248
-rw-r--r--source3/lib/smbldap.c9
-rw-r--r--source3/lib/substitute.c8
-rw-r--r--source3/lib/util_reg.c2
-rw-r--r--source3/lib/util_str.c92
-rw-r--r--source3/libads/ldap.c16
-rw-r--r--source3/libsmb/clifile.c8
-rw-r--r--source3/libsmb/climessage.c4
-rw-r--r--source3/libsmb/clitrans.c10
-rw-r--r--source3/libsmb/smbencrypt.c14
-rw-r--r--source3/passdb/pdb_ldap.c22
-rw-r--r--source3/passdb/secrets.c8
-rw-r--r--source3/smbd/mangle_hash.c20
-rw-r--r--source3/smbd/statcache.c2
-rw-r--r--source3/utils/net_conf.c6
-rw-r--r--source3/utils/net_usershare.c12
-rw-r--r--source3/utils/ntlm_auth_diagnostics.c26
-rw-r--r--source3/web/cgi.c4
-rw-r--r--source3/web/statuspage.c4
-rw-r--r--source3/web/swat.c20
21 files changed, 190 insertions, 356 deletions
diff --git a/source3/include/proto.h b/source3/include/proto.h
index 5a168380a7..718c6b400b 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -348,30 +348,23 @@ void init_iconv(void);
size_t convert_string(charset_t from, charset_t to,
void const *src, size_t srclen,
void *dest, size_t destlen, bool allow_bad_conv);
-bool convert_string_allocate(TALLOC_CTX *ctx, charset_t from, charset_t to,
- void const *src, size_t srclen, void *dst,
- size_t *converted_size, bool allow_bad_conv);
size_t unix_strupper(const char *src, size_t srclen, char *dest, size_t destlen);
-char *strdup_upper(const char *s);
char *talloc_strdup_upper(TALLOC_CTX *ctx, const char *s);
+char *strupper_talloc(TALLOC_CTX *ctx, const char *s);
size_t unix_strlower(const char *src, size_t srclen, char *dest, size_t destlen);
-char *strdup_lower(const char *s);
char *talloc_strdup_lower(TALLOC_CTX *ctx, const char *s);
+char *strlower_talloc(TALLOC_CTX *ctx, const char *s);
size_t ucs2_align(const void *base_ptr, const void *p, int flags);
size_t push_ascii(void *dest, const char *src, size_t dest_len, int flags);
size_t push_ascii_fstring(void *dest, const char *src);
size_t push_ascii_nstring(void *dest, const char *src);
-bool push_ascii_allocate(char **dest, const char *src, size_t *converted_size);
size_t pull_ascii(char *dest, const void *src, size_t dest_len, size_t src_len, int flags);
size_t pull_ascii_fstring(char *dest, const void *src);
size_t pull_ascii_nstring(char *dest, size_t dest_len, const void *src);
size_t push_ucs2(const void *base_ptr, void *dest, const char *src, size_t dest_len, int flags);
-bool push_ucs2_allocate(smb_ucs2_t **dest, const char *src,
- size_t *converted_size);
size_t push_utf8_fstring(void *dest, const char *src);
bool push_utf8_talloc(TALLOC_CTX *ctx, char **dest, const char *src,
size_t *converted_size);
-bool push_utf8_allocate(char **dest, const char *src, size_t *converted_size);
size_t pull_ucs2(const void *base_ptr, char *dest, const void *src, size_t dest_len, size_t src_len, int flags);
size_t pull_ucs2_base_talloc(TALLOC_CTX *ctx,
const void *base_ptr,
diff --git a/source3/lib/charcnv.c b/source3/lib/charcnv.c
index 0c0d654e99..ab00209a8e 100644
--- a/source3/lib/charcnv.c
+++ b/source3/lib/charcnv.c
@@ -518,14 +518,12 @@ size_t convert_string(charset_t from, charset_t to,
}
/**
- * Convert between character sets, allocating a new buffer for the result.
+ * Convert between character sets, allocating a new buffer using talloc for the result.
*
- * @param ctx TALLOC_CTX to use to allocate with. If NULL use malloc.
- * (this is a bad interface and needs fixing. JRA).
* @param srclen length of source buffer.
* @param dest always set at least to NULL
- * @param converted_size set to the size of the allocated buffer on return
- * true
+ * @parm converted_size set to the number of bytes occupied by the string in
+ * the destination on success.
* @note -1 is not accepted for srclen.
*
* @return true if new buffer was correctly allocated, and string was
@@ -535,11 +533,11 @@ size_t convert_string(charset_t from, charset_t to,
*
* I hate the goto's in this function. It's embarressing.....
* There has to be a cleaner way to do this. JRA.
- **/
+ */
+bool convert_string_talloc(TALLOC_CTX *ctx, charset_t from, charset_t to,
+ void const *src, size_t srclen, void *dst,
+ size_t *converted_size, bool allow_bad_conv)
-bool convert_string_allocate(TALLOC_CTX *ctx, charset_t from, charset_t to,
- void const *src, size_t srclen, void *dst,
- size_t *converted_size, bool allow_bad_conv)
{
size_t i_len, o_len, destlen = (srclen * 3) / 2;
size_t retval;
@@ -576,7 +574,7 @@ bool convert_string_allocate(TALLOC_CTX *ctx, charset_t from, charset_t to,
if (descriptor == (smb_iconv_t)-1 || descriptor == (smb_iconv_t)0) {
if (!conv_silent)
- DEBUG(0,("convert_string_allocate: Conversion not supported.\n"));
+ DEBUG(0,("convert_string_talloc: Conversion not supported.\n"));
errno = EOPNOTSUPP;
return false;
}
@@ -587,7 +585,7 @@ bool convert_string_allocate(TALLOC_CTX *ctx, charset_t from, charset_t to,
if ((destlen*2)+2 < destlen) {
/* wrapped ! abort. */
if (!conv_silent)
- DEBUG(0, ("convert_string_allocate: destlen wrapped !\n"));
+ DEBUG(0, ("convert_string_talloc: destlen wrapped !\n"));
if (!ctx)
SAFE_FREE(outbuf);
errno = EOPNOTSUPP;
@@ -597,14 +595,10 @@ bool convert_string_allocate(TALLOC_CTX *ctx, charset_t from, charset_t to,
}
/* +2 is for ucs2 null termination. */
- if (ctx) {
- ob = (char *)TALLOC_REALLOC(ctx, ob, destlen + 2);
- } else {
- ob = (char *)SMB_REALLOC(ob, destlen + 2);
- }
+ ob = (char *)TALLOC_REALLOC(ctx, ob, destlen + 2);
if (!ob) {
- DEBUG(0, ("convert_string_allocate: realloc failed!\n"));
+ DEBUG(0, ("convert_string_talloc: realloc failed!\n"));
errno = ENOMEM;
return false;
}
@@ -623,7 +617,7 @@ bool convert_string_allocate(TALLOC_CTX *ctx, charset_t from, charset_t to,
case EINVAL:
reason="Incomplete multibyte sequence";
if (!conv_silent)
- DEBUG(3,("convert_string_allocate: Conversion error: %s(%s)\n",reason,inbuf));
+ DEBUG(3,("convert_string_talloc: Conversion error: %s(%s)\n",reason,inbuf));
if (allow_bad_conv)
goto use_as_is;
break;
@@ -632,7 +626,7 @@ bool convert_string_allocate(TALLOC_CTX *ctx, charset_t from, charset_t to,
case EILSEQ:
reason="Illegal multibyte sequence";
if (!conv_silent)
- DEBUG(3,("convert_string_allocate: Conversion error: %s(%s)\n",reason,inbuf));
+ DEBUG(3,("convert_string_talloc: Conversion error: %s(%s)\n",reason,inbuf));
if (allow_bad_conv)
goto use_as_is;
break;
@@ -640,11 +634,7 @@ bool convert_string_allocate(TALLOC_CTX *ctx, charset_t from, charset_t to,
if (!conv_silent)
DEBUG(0,("Conversion error: %s(%s)\n",reason,inbuf));
/* smb_panic(reason); */
- if (ctx) {
- TALLOC_FREE(ob);
- } else {
- SAFE_FREE(ob);
- }
+ TALLOC_FREE(ob);
return false;
}
@@ -657,15 +647,11 @@ bool convert_string_allocate(TALLOC_CTX *ctx, charset_t from, charset_t to,
*/
if (o_len > 1024) {
/* We're shrinking here so we know the +2 is safe from wrap. */
- if (ctx) {
- ob = (char *)TALLOC_REALLOC(ctx,ob,destlen + 2);
- } else {
- ob = (char *)SMB_REALLOC(ob,destlen + 2);
- }
+ ob = (char *)TALLOC_REALLOC(ctx,ob,destlen + 2);
}
if (destlen && !ob) {
- DEBUG(0, ("convert_string_allocate: out of memory!\n"));
+ DEBUG(0, ("convert_string_talloc: out of memory!\n"));
errno = ENOMEM;
return false;
}
@@ -763,35 +749,12 @@ bool convert_string_allocate(TALLOC_CTX *ctx, charset_t from, charset_t to,
}
}
-/**
- * Convert between character sets, allocating a new buffer using talloc for the result.
- *
- * @param srclen length of source buffer.
- * @param dest always set at least to NULL
- * @parm converted_size set to the number of bytes occupied by the string in
- * the destination on success.
- * @note -1 is not accepted for srclen.
- *
- * @return true if new buffer was correctly allocated, and string was
- * converted.
- */
-bool convert_string_talloc(TALLOC_CTX *ctx, charset_t from, charset_t to,
- void const *src, size_t srclen, void *dst,
- size_t *converted_size, bool allow_bad_conv)
-{
- void **dest = (void **)dst;
-
- *dest = NULL;
- return convert_string_allocate(ctx, from, to, src, srclen, dest,
- converted_size, allow_bad_conv);
-}
-
size_t unix_strupper(const char *src, size_t srclen, char *dest, size_t destlen)
{
size_t size;
smb_ucs2_t *buffer;
- if (!push_ucs2_allocate(&buffer, src, &size)) {
+ if (!push_ucs2_talloc(NULL, &buffer, src, &size)) {
return (size_t)-1;
}
@@ -801,71 +764,11 @@ size_t unix_strupper(const char *src, size_t srclen, char *dest, size_t destlen)
}
size = convert_string(CH_UTF16LE, CH_UNIX, buffer, size, dest, destlen, True);
- free(buffer);
+ TALLOC_FREE(buffer);
return size;
}
/**
- strdup() a unix string to upper case.
-**/
-
-char *strdup_upper(const char *s)
-{
- char *out_buffer = SMB_STRDUP(s);
- const unsigned char *p = (const unsigned char *)s;
- unsigned char *q = (unsigned char *)out_buffer;
-
- if (!q) {
- return NULL;
- }
-
- /* this is quite a common operation, so we want it to be
- fast. We optimise for the ascii case, knowing that all our
- supported multi-byte character sets are ascii-compatible
- (ie. they match for the first 128 chars) */
-
- while (*p) {
- if (*p & 0x80)
- break;
- *q++ = toupper_ascii_fast(*p);
- p++;
- }
-
- if (*p) {
- /* MB case. */
- size_t converted_size, converted_size2;
- smb_ucs2_t *buffer = NULL;
-
- SAFE_FREE(out_buffer);
- if (!convert_string_allocate(NULL, CH_UNIX, CH_UTF16LE, s,
- strlen(s) + 1,
- (void **)(void *)&buffer,
- &converted_size, True))
- {
- return NULL;
- }
-
- strupper_w(buffer);
-
- if (!convert_string_allocate(NULL, CH_UTF16LE, CH_UNIX, buffer,
- converted_size,
- (void **)(void *)&out_buffer,
- &converted_size2, True))
- {
- TALLOC_FREE(buffer);
- return NULL;
- }
-
- /* Don't need the intermediate buffer
- * anymore.
- */
- TALLOC_FREE(buffer);
- }
-
- return out_buffer;
-}
-
-/**
talloc_strdup() a unix string to upper case.
**/
@@ -925,51 +828,31 @@ char *talloc_strdup_upper(TALLOC_CTX *ctx, const char *s)
return out_buffer;
}
+char *strupper_talloc(TALLOC_CTX *ctx, const char *s) {
+ return talloc_strdup_upper(ctx, s);
+}
+
+
size_t unix_strlower(const char *src, size_t srclen, char *dest, size_t destlen)
{
size_t size;
smb_ucs2_t *buffer = NULL;
- if (!convert_string_allocate(NULL, CH_UNIX, CH_UTF16LE, src, srclen,
- (void **)(void *)&buffer, &size,
- True))
+ if (!convert_string_talloc(NULL, CH_UNIX, CH_UTF16LE, src, srclen,
+ (void **)(void *)&buffer, &size,
+ True))
{
smb_panic("failed to create UCS2 buffer");
}
if (!strlower_w(buffer) && (dest == src)) {
- SAFE_FREE(buffer);
+ TALLOC_FREE(buffer);
return srclen;
}
size = convert_string(CH_UTF16LE, CH_UNIX, buffer, size, dest, destlen, True);
- SAFE_FREE(buffer);
+ TALLOC_FREE(buffer);
return size;
}
-/**
- strdup() a unix string to lower case.
-**/
-
-char *strdup_lower(const char *s)
-{
- size_t converted_size;
- smb_ucs2_t *buffer = NULL;
- char *out_buffer;
-
- if (!push_ucs2_allocate(&buffer, s, &converted_size)) {
- return NULL;
- }
-
- strlower_w(buffer);
-
- if (!pull_ucs2_allocate(&out_buffer, buffer, &converted_size)) {
- SAFE_FREE(buffer);
- return NULL;
- }
-
- SAFE_FREE(buffer);
-
- return out_buffer;
-}
char *talloc_strdup_lower(TALLOC_CTX *ctx, const char *s)
{
@@ -993,6 +876,9 @@ char *talloc_strdup_lower(TALLOC_CTX *ctx, const char *s)
return out_buffer;
}
+char *strlower_talloc(TALLOC_CTX *ctx, const char *s) {
+ return talloc_strdup_lower(ctx, s);
+}
size_t ucs2_align(const void *base_ptr, const void *p, int flags)
{
@@ -1066,7 +952,7 @@ size_t push_ascii_nstring(void *dest, const char *src)
smb_ucs2_t *buffer;
conv_silent = True;
- if (!push_ucs2_allocate(&buffer, src, &buffer_len)) {
+ if (!push_ucs2_talloc(NULL, &buffer, src, &buffer_len)) {
smb_panic("failed to create UCS2 buffer");
}
@@ -1088,8 +974,8 @@ size_t push_ascii_nstring(void *dest, const char *src)
}
((char *)dest)[dest_len] = '\0';
- SAFE_FREE(buffer);
conv_silent = False;
+ TALLOC_FREE(buffer);
return dest_len;
}
@@ -1097,13 +983,13 @@ size_t push_ascii_nstring(void *dest, const char *src)
Push and malloc an ascii string. src and dest null terminated.
********************************************************************/
-bool push_ascii_allocate(char **dest, const char *src, size_t *converted_size)
+bool push_ascii_talloc(TALLOC_CTX *mem_ctx, char **dest, const char *src, size_t *converted_size)
{
size_t src_len = strlen(src)+1;
*dest = NULL;
- return convert_string_allocate(NULL, CH_UNIX, CH_DOS, src, src_len,
- (void **)dest, converted_size, True);
+ return convert_string_talloc(mem_ctx, CH_UNIX, CH_DOS, src, src_len,
+ (void **)dest, converted_size, True);
}
/**
@@ -1179,21 +1065,14 @@ size_t pull_ascii(char *dest, const void *src, size_t dest_len, size_t src_len,
**/
static size_t pull_ascii_base_talloc(TALLOC_CTX *ctx,
- char **ppdest,
- const void *src,
- size_t src_len,
- int flags)
+ char **ppdest,
+ const void *src,
+ size_t src_len,
+ int flags)
{
char *dest = NULL;
size_t dest_len;
-#ifdef DEVELOPER
- /* Ensure we never use the braindead "malloc" varient. */
- if (ctx == NULL) {
- smb_panic("NULL talloc CTX in pull_ascii_base_talloc\n");
- }
-#endif
-
*ppdest = NULL;
if (!src_len) {
@@ -1229,7 +1108,7 @@ static size_t pull_ascii_base_talloc(TALLOC_CTX *ctx,
/* src_len != -1 here. */
- if (!convert_string_allocate(ctx, CH_DOS, CH_UNIX, src, src_len, &dest,
+ if (!convert_string_talloc(ctx, CH_DOS, CH_UNIX, src, src_len, &dest,
&dest_len, True)) {
dest_len = 0;
}
@@ -1371,27 +1250,6 @@ bool push_ucs2_talloc(TALLOC_CTX *ctx, smb_ucs2_t **dest, const char *src,
/**
- * Copy a string from a unix char* src to a UCS2 destination, allocating a buffer
- *
- * @param dest always set at least to NULL
- * @parm converted_size set to the number of bytes occupied by the string in
- * the destination on success.
- *
- * @return true if new buffer was correctly allocated, and string was
- * converted.
- **/
-
-bool push_ucs2_allocate(smb_ucs2_t **dest, const char *src,
- size_t *converted_size)
-{
- size_t src_len = strlen(src)+1;
-
- *dest = NULL;
- return convert_string_allocate(NULL, CH_UNIX, CH_UTF16LE, src, src_len,
- (void **)dest, converted_size, True);
-}
-
-/**
Copy a string from a char* src to a UTF-8 destination.
Return the number of bytes occupied by the string in the destination
Flags can have:
@@ -1413,7 +1271,7 @@ static size_t push_utf8(void *dest, const char *src, size_t dest_len, int flags)
}
if (flags & STR_UPPER) {
- tmpbuf = strdup_upper(src);
+ tmpbuf = strupper_talloc(NULL, src);
if (!tmpbuf) {
return (size_t)-1;
}
@@ -1427,7 +1285,7 @@ static size_t push_utf8(void *dest, const char *src, size_t dest_len, int flags)
}
ret = convert_string(CH_UNIX, CH_UTF8, src, src_len, dest, dest_len, True);
- SAFE_FREE(tmpbuf);
+ TALLOC_FREE(tmpbuf);
return ret;
}
@@ -1458,26 +1316,6 @@ bool push_utf8_talloc(TALLOC_CTX *ctx, char **dest, const char *src,
}
/**
- * Copy a string from a unix char* src to a UTF-8 destination, allocating a buffer
- *
- * @param dest always set at least to NULL
- * @parm converted_size set to the number of bytes occupied by the string in
- * the destination on success.
- *
- * @return true if new buffer was correctly allocated, and string was
- * converted.
- **/
-
-bool push_utf8_allocate(char **dest, const char *src, size_t *converted_size)
-{
- size_t src_len = strlen(src)+1;
-
- *dest = NULL;
- return convert_string_allocate(NULL, CH_UNIX, CH_UTF8, src, src_len,
- (void **)dest, converted_size, True);
-}
-
-/**
Copy a string from a ucs2 source to a unix char* destination.
Flags can have:
STR_TERMINATE means the string in src is null terminated.
diff --git a/source3/lib/smbldap.c b/source3/lib/smbldap.c
index 4f54f9ad58..63629265f1 100644
--- a/source3/lib/smbldap.c
+++ b/source3/lib/smbldap.c
@@ -444,12 +444,15 @@ ATTRIB_MAP_ENTRY sidmap_attr_list[] = {
/* notreached. */
}
- if (!push_utf8_allocate(&utf8_value, value, &converted_size)) {
+ if (!push_utf8_talloc(talloc_tos(), &utf8_value, value, &converted_size)) {
smb_panic("smbldap_set_mod: String conversion failure!");
/* notreached. */
}
-
- mods[i]->mod_values[j] = utf8_value;
+
+
+ mods[i]->mod_values[j] = SMB_STRDUP(utf8_value);
+ TALLOC_FREE(utf8_value);
+ SMB_ASSERT(mods[i]->mod_values[j] != NULL);
mods[i]->mod_values[j + 1] = NULL;
}
diff --git a/source3/lib/substitute.c b/source3/lib/substitute.c
index 0cb326961d..c9dc1d2eb4 100644
--- a/source3/lib/substitute.c
+++ b/source3/lib/substitute.c
@@ -576,7 +576,7 @@ char *alloc_sub_basic(const char *smb_name, const char *domain_name,
switch (*(p+1)) {
case 'U' :
- r = strdup_lower(smb_name);
+ r = strlower_talloc(tmp_ctx, smb_name);
if (r == NULL) {
goto error;
}
@@ -584,7 +584,7 @@ char *alloc_sub_basic(const char *smb_name, const char *domain_name,
break;
case 'G' : {
struct passwd *pass;
- r = SMB_STRDUP(smb_name);
+ r = talloc_strdup(tmp_ctx, smb_name);
if (r == NULL) {
goto error;
}
@@ -598,7 +598,7 @@ char *alloc_sub_basic(const char *smb_name, const char *domain_name,
break;
}
case 'D' :
- r = strdup_upper(domain_name);
+ r = strupper_talloc(tmp_ctx, domain_name);
if (r == NULL) {
goto error;
}
@@ -678,7 +678,7 @@ char *alloc_sub_basic(const char *smb_name, const char *domain_name,
}
p++;
- SAFE_FREE(r);
+ TALLOC_FREE(r);
if (a_string == NULL) {
goto done;
diff --git a/source3/lib/util_reg.c b/source3/lib/util_reg.c
index 6570bb072d..96717e33d3 100644
--- a/source3/lib/util_reg.c
+++ b/source3/lib/util_reg.c
@@ -93,7 +93,7 @@ WERROR reg_pull_multi_sz(TALLOC_CTX *mem_ctx, const void *buf, size_t len,
size_t dstlen, thislen;
thislen = strnlen_w(p, len) + 1;
- if (!convert_string_allocate(*values, CH_UTF16LE, CH_UNIX,
+ if (!convert_string_talloc(*values, CH_UTF16LE, CH_UNIX,
p, thislen*2, (void *)&val, &dstlen, true)) {
TALLOC_FREE(*values);
return WERR_NOMEM;
diff --git a/source3/lib/util_str.c b/source3/lib/util_str.c
index b9ccb83e55..6fd477b537 100644
--- a/source3/lib/util_str.c
+++ b/source3/lib/util_str.c
@@ -96,15 +96,15 @@ int StrCaseCmp(const char *s, const char *t)
return +1;
}
- if (!push_ucs2_allocate(&buffer_s, ps, &size)) {
+ if (!push_ucs2_talloc(NULL, &buffer_s, ps, &size)) {
return strcmp(ps, pt);
/* Not quite the right answer, but finding the right one
under this failure case is expensive, and it's pretty
close */
}
- if (!push_ucs2_allocate(&buffer_t, pt, &size)) {
- SAFE_FREE(buffer_s);
+ if (!push_ucs2_talloc(NULL, &buffer_t, pt, &size)) {
+ TALLOC_FREE(buffer_s);
return strcmp(ps, pt);
/* Not quite the right answer, but finding the right one
under this failure case is expensive, and it's pretty
@@ -112,8 +112,8 @@ int StrCaseCmp(const char *s, const char *t)
}
ret = strcasecmp_w(buffer_s, buffer_t);
- SAFE_FREE(buffer_s);
- SAFE_FREE(buffer_t);
+ TALLOC_FREE(buffer_s);
+ TALLOC_FREE(buffer_t);
return ret;
}
@@ -157,15 +157,15 @@ int StrnCaseCmp(const char *s, const char *t, size_t len)
return 0;
}
- if (!push_ucs2_allocate(&buffer_s, ps, &size)) {
+ if (!push_ucs2_talloc(NULL, &buffer_s, ps, &size)) {
return strncmp(ps, pt, len-n);
/* Not quite the right answer, but finding the right one
under this failure case is expensive,
and it's pretty close */
}
- if (!push_ucs2_allocate(&buffer_t, pt, &size)) {
- SAFE_FREE(buffer_s);
+ if (!push_ucs2_talloc(NULL, &buffer_t, pt, &size)) {
+ TALLOC_FREE(buffer_s);
return strncmp(ps, pt, len-n);
/* Not quite the right answer, but finding the right one
under this failure case is expensive,
@@ -173,8 +173,8 @@ int StrnCaseCmp(const char *s, const char *t, size_t len)
}
ret = strncasecmp_w(buffer_s, buffer_t, len-n);
- SAFE_FREE(buffer_s);
- SAFE_FREE(buffer_t);
+ TALLOC_FREE(buffer_s);
+ TALLOC_FREE(buffer_t);
return ret;
}
@@ -366,11 +366,11 @@ size_t str_charnum(const char *s)
{
size_t ret, converted_size;
smb_ucs2_t *tmpbuf2 = NULL;
- if (!push_ucs2_allocate(&tmpbuf2, s, &converted_size)) {
+ if (!push_ucs2_talloc(NULL, &tmpbuf2, s, &converted_size)) {
return 0;
}
ret = strlen_w(tmpbuf2);
- SAFE_FREE(tmpbuf2);
+ TALLOC_FREE(tmpbuf2);
return ret;
}
@@ -384,11 +384,11 @@ size_t str_ascii_charnum(const char *s)
{
size_t ret, converted_size;
char *tmpbuf2 = NULL;
- if (!push_ascii_allocate(&tmpbuf2, s, &converted_size)) {
+ if (!push_ascii_talloc(NULL, &tmpbuf2, s, &converted_size)) {
return 0;
}
ret = strlen(tmpbuf2);
- SAFE_FREE(tmpbuf2);
+ TALLOC_FREE(tmpbuf2);
return ret;
}
@@ -455,7 +455,7 @@ bool strhasupper(const char *s)
bool ret;
size_t converted_size;
- if (!push_ucs2_allocate(&tmp, s, &converted_size)) {
+ if (!push_ucs2_talloc(NULL, &tmp, s, &converted_size)) {
return false;
}
@@ -466,7 +466,7 @@ bool strhasupper(const char *s)
}
ret = (*p != 0);
- SAFE_FREE(tmp);
+ TALLOC_FREE(tmp);
return ret;
}
@@ -480,7 +480,7 @@ bool strhaslower(const char *s)
bool ret;
size_t converted_size;
- if (!push_ucs2_allocate(&tmp, s, &converted_size)) {
+ if (!push_ucs2_talloc(NULL, &tmp, s, &converted_size)) {
return false;
}
@@ -491,7 +491,7 @@ bool strhaslower(const char *s)
}
ret = (*p != 0);
- SAFE_FREE(tmp);
+ TALLOC_FREE(tmp);
return ret;
}
@@ -1177,24 +1177,24 @@ char *strchr_m(const char *src, char c)
s = src;
#endif
- if (!push_ucs2_allocate(&ws, s, &converted_size)) {
+ if (!push_ucs2_talloc(NULL, &ws, s, &converted_size)) {
/* Wrong answer, but what can we do... */
return strchr(src, c);
}
p = strchr_w(ws, UCS2_CHAR(c));
if (!p) {
- SAFE_FREE(ws);
+ TALLOC_FREE(ws);
return NULL;
}
*p = 0;
- if (!pull_ucs2_allocate(&s2, ws, &converted_size)) {
+ if (!pull_ucs2_talloc(NULL, &s2, ws, &converted_size)) {
SAFE_FREE(ws);
/* Wrong answer, but what can we do... */
return strchr(src, c);
}
ret = (char *)(s+strlen(s2));
- SAFE_FREE(ws);
- SAFE_FREE(s2);
+ TALLOC_FREE(ws);
+ TALLOC_FREE(s2);
return ret;
}
@@ -1248,24 +1248,24 @@ char *strrchr_m(const char *s, char c)
char *ret;
size_t converted_size;
- if (!push_ucs2_allocate(&ws, s, &converted_size)) {
+ if (!push_ucs2_talloc(NULL, &ws, s, &converted_size)) {
/* Wrong answer, but what can we do. */
return strrchr(s, c);
}
p = strrchr_w(ws, UCS2_CHAR(c));
if (!p) {
- SAFE_FREE(ws);
+ TALLOC_FREE(ws);
return NULL;
}
*p = 0;
- if (!pull_ucs2_allocate(&s2, ws, &converted_size)) {
- SAFE_FREE(ws);
+ if (!pull_ucs2_talloc(NULL, &s2, ws, &converted_size)) {
+ TALLOC_FREE(ws);
/* Wrong answer, but what can we do. */
return strrchr(s, c);
}
ret = (char *)(s+strlen(s2));
- SAFE_FREE(ws);
- SAFE_FREE(s2);
+ TALLOC_FREE(ws);
+ TALLOC_FREE(s2);
return ret;
}
}
@@ -1283,24 +1283,24 @@ char *strnrchr_m(const char *s, char c, unsigned int n)
char *ret;
size_t converted_size;
- if (!push_ucs2_allocate(&ws, s, &converted_size)) {
+ if (!push_ucs2_talloc(NULL, &ws, s, &converted_size)) {
/* Too hard to try and get right. */
return NULL;
}
p = strnrchr_w(ws, UCS2_CHAR(c), n);
if (!p) {
- SAFE_FREE(ws);
+ TALLOC_FREE(ws);
return NULL;
}
*p = 0;
- if (!pull_ucs2_allocate(&s2, ws, &converted_size)) {
- SAFE_FREE(ws);
+ if (!pull_ucs2_talloc(NULL, &s2, ws, &converted_size)) {
+ TALLOC_FREE(ws);
/* Too hard to try and get right. */
return NULL;
}
ret = (char *)(s+strlen(s2));
- SAFE_FREE(ws);
- SAFE_FREE(s2);
+ TALLOC_FREE(ws);
+ TALLOC_FREE(s2);
return ret;
}
@@ -1352,13 +1352,13 @@ char *strstr_m(const char *src, const char *findstr)
s = src;
#endif
- if (!push_ucs2_allocate(&src_w, src, &converted_size)) {
+ if (!push_ucs2_talloc(NULL, &src_w, src, &converted_size)) {
DEBUG(0,("strstr_m: src malloc fail\n"));
return NULL;
}
- if (!push_ucs2_allocate(&find_w, findstr, &converted_size)) {
- SAFE_FREE(src_w);
+ if (!push_ucs2_talloc(NULL, &find_w, findstr, &converted_size)) {
+ TALLOC_FREE(src_w);
DEBUG(0,("strstr_m: find malloc fail\n"));
return NULL;
}
@@ -1366,22 +1366,22 @@ char *strstr_m(const char *src, const char *findstr)
p = strstr_w(src_w, find_w);
if (!p) {
- SAFE_FREE(src_w);
- SAFE_FREE(find_w);
+ TALLOC_FREE(src_w);
+ TALLOC_FREE(find_w);
return NULL;
}
*p = 0;
- if (!pull_ucs2_allocate(&s2, src_w, &converted_size)) {
- SAFE_FREE(src_w);
- SAFE_FREE(find_w);
+ if (!pull_ucs2_talloc(NULL, &s2, src_w, &converted_size)) {
+ TALLOC_FREE(src_w);
+ TALLOC_FREE(find_w);
DEBUG(0,("strstr_m: dest malloc fail\n"));
return NULL;
}
retp = (char *)(s+strlen(s2));
- SAFE_FREE(src_w);
- SAFE_FREE(find_w);
- SAFE_FREE(s2);
+ TALLOC_FREE(src_w);
+ TALLOC_FREE(find_w);
+ TALLOC_FREE(s2);
return retp;
}
diff --git a/source3/libads/ldap.c b/source3/libads/ldap.c
index 841ea8caae..9ffbd57e4a 100644
--- a/source3/libads/ldap.c
+++ b/source3/libads/ldap.c
@@ -1500,7 +1500,7 @@ ADS_STATUS ads_gen_mod(ADS_STRUCT *ads, const char *mod_dn, ADS_MODLIST mods)
controls[0] = &PermitModify;
controls[1] = NULL;
- if (!push_utf8_allocate(&utf8_dn, mod_dn, &converted_size)) {
+ if (!push_utf8_talloc(talloc_tos(), &utf8_dn, mod_dn, &converted_size)) {
return ADS_ERROR_NT(NT_STATUS_NO_MEMORY);
}
@@ -1510,7 +1510,7 @@ ADS_STATUS ads_gen_mod(ADS_STRUCT *ads, const char *mod_dn, ADS_MODLIST mods)
mods[i] = NULL;
ret = ldap_modify_ext_s(ads->ldap.ld, utf8_dn,
(LDAPMod **) mods, controls, NULL);
- SAFE_FREE(utf8_dn);
+ TALLOC_FREE(utf8_dn);
return ADS_ERROR(ret);
}
@@ -1527,8 +1527,8 @@ ADS_STATUS ads_gen_add(ADS_STRUCT *ads, const char *new_dn, ADS_MODLIST mods)
char *utf8_dn = NULL;
size_t converted_size;
- if (!push_utf8_allocate(&utf8_dn, new_dn, &converted_size)) {
- DEBUG(1, ("ads_gen_add: push_utf8_allocate failed!"));
+ if (!push_utf8_talloc(talloc_tos(), &utf8_dn, new_dn, &converted_size)) {
+ DEBUG(1, ("ads_gen_add: push_utf8_talloc failed!"));
return ADS_ERROR_NT(NT_STATUS_NO_MEMORY);
}
@@ -1538,7 +1538,7 @@ ADS_STATUS ads_gen_add(ADS_STRUCT *ads, const char *new_dn, ADS_MODLIST mods)
mods[i] = NULL;
ret = ldap_add_s(ads->ldap.ld, utf8_dn, (LDAPMod**)mods);
- SAFE_FREE(utf8_dn);
+ TALLOC_FREE(utf8_dn);
return ADS_ERROR(ret);
}
@@ -1553,13 +1553,13 @@ ADS_STATUS ads_del_dn(ADS_STRUCT *ads, char *del_dn)
int ret;
char *utf8_dn = NULL;
size_t converted_size;
- if (!push_utf8_allocate(&utf8_dn, del_dn, &converted_size)) {
- DEBUG(1, ("ads_del_dn: push_utf8_allocate failed!"));
+ if (!push_utf8_talloc(talloc_tos(), &utf8_dn, del_dn, &converted_size)) {
+ DEBUG(1, ("ads_del_dn: push_utf8_talloc failed!"));
return ADS_ERROR_NT(NT_STATUS_NO_MEMORY);
}
ret = ldap_delete_s(ads->ldap.ld, utf8_dn);
- SAFE_FREE(utf8_dn);
+ TALLOC_FREE(utf8_dn);
return ADS_ERROR(ret);
}
diff --git a/source3/libsmb/clifile.c b/source3/libsmb/clifile.c
index 4293828214..0a1168fd0f 100644
--- a/source3/libsmb/clifile.c
+++ b/source3/libsmb/clifile.c
@@ -968,10 +968,10 @@ uint8_t *smb_bytes_push_str(uint8_t *buf, bool ucs2,
buflen += 1;
}
- if (!convert_string_allocate(talloc_tos(), CH_UNIX,
- ucs2 ? CH_UTF16LE : CH_DOS,
- str, str_len, &converted,
- &converted_size, true)) {
+ if (!convert_string_talloc(talloc_tos(), CH_UNIX,
+ ucs2 ? CH_UTF16LE : CH_DOS,
+ str, str_len, &converted,
+ &converted_size, true)) {
return NULL;
}
diff --git a/source3/libsmb/climessage.c b/source3/libsmb/climessage.c
index 808190e79c..6538902f5d 100644
--- a/source3/libsmb/climessage.c
+++ b/source3/libsmb/climessage.c
@@ -85,7 +85,7 @@ int cli_message_text_build(struct cli_state *cli, const char *msg, int len, int
p = smb_buf(cli->outbuf);
*p++ = 1;
- if (!convert_string_allocate(NULL, CH_UNIX, CH_DOS, msg, len,
+ if (!convert_string_talloc(talloc_tos(), CH_UNIX, CH_DOS, msg, len,
(void **)(void *)&msgdos, &lendos, True) || !msgdos) {
DEBUG(3,("Conversion failed, sending message in UNIX charset\n"));
SSVAL(p, 0, len); p += 2;
@@ -101,7 +101,7 @@ int cli_message_text_build(struct cli_state *cli, const char *msg, int len, int
}
memcpy(p, msgdos, lendos);
p += lendos;
- SAFE_FREE(msgdos);
+ TALLOC_FREE(msgdos);
}
cli_setup_bcc(cli, p);
diff --git a/source3/libsmb/clitrans.c b/source3/libsmb/clitrans.c
index 3a6aa9e72c..8fc7a5269f 100644
--- a/source3/libsmb/clitrans.c
+++ b/source3/libsmb/clitrans.c
@@ -1050,11 +1050,11 @@ struct tevent_req *cli_trans_send(
ZERO_STRUCT(state->rdata);
if ((pipe_name != NULL)
- && (!convert_string_allocate(state, CH_UNIX,
- cli_ucs2(cli) ? CH_UTF16LE : CH_DOS,
- pipe_name, strlen(pipe_name) + 1,
- &state->pipe_name_conv,
- &state->pipe_name_conv_len, true))) {
+ && (!convert_string_talloc(state, CH_UNIX,
+ cli_ucs2(cli) ? CH_UTF16LE : CH_DOS,
+ pipe_name, strlen(pipe_name) + 1,
+ &state->pipe_name_conv,
+ &state->pipe_name_conv_len, true))) {
tevent_req_nterror(req, NT_STATUS_NO_MEMORY);
return tevent_req_post(req, ev);
}
diff --git a/source3/libsmb/smbencrypt.c b/source3/libsmb/smbencrypt.c
index a76be3cc1a..27702b9f42 100644
--- a/source3/libsmb/smbencrypt.c
+++ b/source3/libsmb/smbencrypt.c
@@ -172,16 +172,16 @@ bool ntv2_owf_gen(const uchar owf[16],
HMACMD5Context ctx;
- if (!push_ucs2_allocate(&user, user_in, &user_byte_len)) {
- DEBUG(0, ("push_uss2_allocate() for user failed: %s\n",
+ if (!push_ucs2_talloc(NULL, &user, user_in, &user_byte_len)) {
+ DEBUG(0, ("push_uss2_talloc() for user failed: %s\n",
strerror(errno)));
return False;
}
- if (!push_ucs2_allocate(&domain, domain_in, &domain_byte_len)) {
- DEBUG(0, ("push_uss2_allocate() for domain failed: %s\n",
+ if (!push_ucs2_talloc(NULL, &domain, domain_in, &domain_byte_len)) {
+ DEBUG(0, ("push_uss2_talloc() for domain failed: %s\n",
strerror(errno)));
- SAFE_FREE(user);
+ TALLOC_FREE(user);
return False;
}
@@ -210,8 +210,8 @@ bool ntv2_owf_gen(const uchar owf[16],
dump_data(100, (uint8 *)kr_buf, 16);
#endif
- SAFE_FREE(user);
- SAFE_FREE(domain);
+ TALLOC_FREE(user);
+ TALLOC_FREE(domain);
return True;
}
diff --git a/source3/passdb/pdb_ldap.c b/source3/passdb/pdb_ldap.c
index b706721e77..35ce8bb41a 100644
--- a/source3/passdb/pdb_ldap.c
+++ b/source3/passdb/pdb_ldap.c
@@ -1711,22 +1711,22 @@ static NTSTATUS ldapsam_modify_entry(struct pdb_methods *my_methods,
}
}
- if (!push_utf8_allocate(&utf8_password,
+ if (!push_utf8_talloc(talloc_tos(), &utf8_password,
pdb_get_plaintext_passwd(newpwd),
&converted_size))
{
return NT_STATUS_NO_MEMORY;
}
- if (!push_utf8_allocate(&utf8_dn, dn, &converted_size)) {
- SAFE_FREE(utf8_password);
+ if (!push_utf8_talloc(talloc_tos(), &utf8_dn, dn, &converted_size)) {
+ TALLOC_FREE(utf8_password);
return NT_STATUS_NO_MEMORY;
}
if ((ber = ber_alloc_t(LBER_USE_DER))==NULL) {
DEBUG(0,("ber_alloc_t returns NULL\n"));
- SAFE_FREE(utf8_password);
- SAFE_FREE(utf8_dn);
+ TALLOC_FREE(utf8_password);
+ TALLOC_FREE(utf8_dn);
return NT_STATUS_UNSUCCESSFUL;
}
@@ -1736,21 +1736,21 @@ static NTSTATUS ldapsam_modify_entry(struct pdb_methods *my_methods,
(ber_printf (ber, "n}") < 0)) {
DEBUG(0,("ldapsam_modify_entry: ber_printf returns a value <0\n"));
ber_free(ber,1);
- SAFE_FREE(utf8_dn);
- SAFE_FREE(utf8_password);
+ TALLOC_FREE(utf8_dn);
+ TALLOC_FREE(utf8_password);
return NT_STATUS_UNSUCCESSFUL;
}
if ((rc = ber_flatten (ber, &bv))<0) {
DEBUG(0,("ldapsam_modify_entry: ber_flatten returns a value <0\n"));
ber_free(ber,1);
- SAFE_FREE(utf8_dn);
- SAFE_FREE(utf8_password);
+ TALLOC_FREE(utf8_dn);
+ TALLOC_FREE(utf8_password);
return NT_STATUS_UNSUCCESSFUL;
}
- SAFE_FREE(utf8_dn);
- SAFE_FREE(utf8_password);
+ TALLOC_FREE(utf8_dn);
+ TALLOC_FREE(utf8_password);
ber_free(ber, 1);
if (!ldap_state->is_nds_ldap) {
diff --git a/source3/passdb/secrets.c b/source3/passdb/secrets.c
index 8e64a49e22..2b507d0c4d 100644
--- a/source3/passdb/secrets.c
+++ b/source3/passdb/secrets.c
@@ -720,7 +720,7 @@ bool secrets_store_trusted_domain_password(const char* domain, const char* pwd,
struct trusted_dom_pass pass;
ZERO_STRUCT(pass);
- if (!push_ucs2_allocate(&uni_dom_name, domain, &converted_size)) {
+ if (!push_ucs2_talloc(talloc_tos(), &uni_dom_name, domain, &converted_size)) {
DEBUG(0, ("Could not convert domain name %s to unicode\n",
domain));
return False;
@@ -728,7 +728,7 @@ bool secrets_store_trusted_domain_password(const char* domain, const char* pwd,
strncpy_w(pass.uni_name, uni_dom_name, sizeof(pass.uni_name) - 1);
pass.uni_name_len = strlen_w(uni_dom_name)+1;
- SAFE_FREE(uni_dom_name);
+ TALLOC_FREE(uni_dom_name);
/* last change time */
pass.mod_time = time(NULL);
@@ -742,14 +742,14 @@ bool secrets_store_trusted_domain_password(const char* domain, const char* pwd,
/* Calculate the length. */
pass_len = tdb_trusted_dom_pass_pack(NULL, 0, &pass);
- pass_buf = SMB_MALLOC_ARRAY(uint8, pass_len);
+ pass_buf = talloc_array(talloc_tos(), uint8, pass_len);
if (!pass_buf) {
return false;
}
pass_len = tdb_trusted_dom_pass_pack(pass_buf, pass_len, &pass);
ret = secrets_store(trustdom_keystr(domain), (void *)pass_buf,
pass_len);
- SAFE_FREE(pass_buf);
+ TALLOC_FREE(pass_buf);
return ret;
}
diff --git a/source3/smbd/mangle_hash.c b/source3/smbd/mangle_hash.c
index 96fe4d2cab..94bb184b0f 100644
--- a/source3/smbd/mangle_hash.c
+++ b/source3/smbd/mangle_hash.c
@@ -290,15 +290,15 @@ static bool is_8_3(const char *fname, bool check_case, bool allow_wildcards,
if (strlen(f) > 12)
return False;
- if (!push_ucs2_allocate(&ucs2name, f, &size)) {
- DEBUG(0,("is_8_3: internal error push_ucs2_allocate() failed!\n"));
+ if (!push_ucs2_talloc(NULL, &ucs2name, f, &size)) {
+ DEBUG(0,("is_8_3: internal error push_ucs2_talloc() failed!\n"));
goto done;
}
ret = is_8_3_w(ucs2name, allow_wildcards);
done:
- SAFE_FREE(ucs2name);
+ TALLOC_FREE(ucs2name);
if (!NT_STATUS_IS_OK(ret)) {
return False;
@@ -606,12 +606,12 @@ static bool must_mangle(const char *name,
magic_char = lp_magicchar(p);
- if (!push_ucs2_allocate(&name_ucs2, name, &converted_size)) {
- DEBUG(0, ("push_ucs2_allocate failed!\n"));
+ if (!push_ucs2_talloc(NULL, &name_ucs2, name, &converted_size)) {
+ DEBUG(0, ("push_ucs2_talloc failed!\n"));
return False;
}
status = is_valid_name(name_ucs2, False, False);
- SAFE_FREE(name_ucs2);
+ TALLOC_FREE(name_ucs2);
return NT_STATUS_IS_OK(status);
}
@@ -645,20 +645,20 @@ static bool hash_name_to_8_3(const char *in,
DEBUG(5,("hash_name_to_8_3( %s, cache83 = %s)\n", in,
cache83 ? "True" : "False"));
- if (!push_ucs2_allocate(&in_ucs2, in, &converted_size)) {
- DEBUG(0, ("push_ucs2_allocate failed!\n"));
+ if (!push_ucs2_talloc(NULL, &in_ucs2, in, &converted_size)) {
+ DEBUG(0, ("push_ucs2_talloc failed!\n"));
return False;
}
/* If it's already 8.3, just copy. */
if (NT_STATUS_IS_OK(is_valid_name(in_ucs2, False, False)) &&
NT_STATUS_IS_OK(is_8_3_w(in_ucs2, False))) {
- SAFE_FREE(in_ucs2);
+ TALLOC_FREE(in_ucs2);
safe_strcpy(out, in, 12);
return True;
}
- SAFE_FREE(in_ucs2);
+ TALLOC_FREE(in_ucs2);
if (!to_8_3(magic_char, in, out, default_case)) {
return False;
}
diff --git a/source3/smbd/statcache.c b/source3/smbd/statcache.c
index 72fed008a2..2f7d16790d 100644
--- a/source3/smbd/statcache.c
+++ b/source3/smbd/statcache.c
@@ -205,7 +205,7 @@ bool stat_cache_lookup(connection_struct *conn,
} else {
chk_name = talloc_strdup_upper(ctx,name);
if (!chk_name) {
- DEBUG(0, ("stat_cache_lookup: strdup_upper failed!\n"));
+ DEBUG(0, ("stat_cache_lookup: talloc_strdup_upper failed!\n"));
return False;
}
diff --git a/source3/utils/net_conf.c b/source3/utils/net_conf.c
index b65202ee69..3fa547baf4 100644
--- a/source3/utils/net_conf.c
+++ b/source3/utils/net_conf.c
@@ -766,7 +766,7 @@ static int net_conf_setparm(struct net_context *c, struct smbconf_ctx *conf_ctx,
d_printf("error: out of memory!\n");
goto done;
}
- param = talloc_strdup_lower(mem_ctx, argv[1]);
+ param = strlower_talloc(mem_ctx, argv[1]);
if (param == NULL) {
d_printf("error: out of memory!\n");
goto done;
@@ -818,7 +818,7 @@ static int net_conf_getparm(struct net_context *c, struct smbconf_ctx *conf_ctx,
d_printf("error: out of memory!\n");
goto done;
}
- param = talloc_strdup_lower(mem_ctx, argv[1]);
+ param = strlower_talloc(mem_ctx, argv[1]);
if (param == NULL) {
d_printf("error: out of memory!\n");
goto done;
@@ -868,7 +868,7 @@ static int net_conf_delparm(struct net_context *c, struct smbconf_ctx *conf_ctx,
d_printf("error: out of memory!\n");
goto done;
}
- param = talloc_strdup_lower(mem_ctx, argv[1]);
+ param = strlower_talloc(mem_ctx, argv[1]);
if (param == NULL) {
d_printf("error: out of memory!\n");
goto done;
diff --git a/source3/utils/net_usershare.c b/source3/utils/net_usershare.c
index ce8e82182e..7d3cb287a8 100644
--- a/source3/utils/net_usershare.c
+++ b/source3/utils/net_usershare.c
@@ -154,8 +154,8 @@ static int net_usershare_delete(struct net_context *c, int argc, const char **ar
return net_usershare_delete_usage(c, argc, argv);
}
- if ((sharename = strdup_lower(argv[0])) == NULL) {
- d_fprintf(stderr, "strdup failed\n");
+ if ((sharename = strlower_talloc(talloc_tos(), argv[0])) == NULL) {
+ d_fprintf(stderr, "strlower_talloc failed\n");
return -1;
}
@@ -624,22 +624,22 @@ static int net_usershare_add(struct net_context *c, int argc, const char **argv)
default:
return net_usershare_add_usage(c, argc, argv);
case 2:
- sharename = strdup_lower(argv[0]);
+ sharename = strlower_talloc(ctx, argv[0]);
us_path = argv[1];
break;
case 3:
- sharename = strdup_lower(argv[0]);
+ sharename = strlower_talloc(ctx, argv[0]);
us_path = argv[1];
us_comment = argv[2];
break;
case 4:
- sharename = strdup_lower(argv[0]);
+ sharename = strlower_talloc(ctx, argv[0]);
us_path = argv[1];
us_comment = argv[2];
arg_acl = argv[3];
break;
case 5:
- sharename = strdup_lower(argv[0]);
+ sharename = strlower_talloc(ctx, argv[0]);
us_path = argv[1];
us_comment = argv[2];
arg_acl = argv[3];
diff --git a/source3/utils/ntlm_auth_diagnostics.c b/source3/utils/ntlm_auth_diagnostics.c
index dcdc8e9a40..17801b2a80 100644
--- a/source3/utils/ntlm_auth_diagnostics.c
+++ b/source3/utils/ntlm_auth_diagnostics.c
@@ -458,31 +458,31 @@ static bool test_plaintext(enum ntlm_break break_which)
flags |= WBFLAG_PAM_LMKEY;
flags |= WBFLAG_PAM_USER_SESSION_KEY;
- if (!push_ucs2_allocate(&nt_response_ucs2, opt_password,
+ if (!push_ucs2_talloc(NULL, &nt_response_ucs2, opt_password,
&converted_size))
{
- DEBUG(0, ("push_ucs2_allocate failed!\n"));
+ DEBUG(0, ("push_ucs2_talloc failed!\n"));
exit(1);
}
nt_response.data = (unsigned char *)nt_response_ucs2;
nt_response.length = strlen_w(nt_response_ucs2)*sizeof(smb_ucs2_t);
- if ((password = strdup_upper(opt_password)) == NULL) {
- DEBUG(0, ("strdup_upper failed!\n"));
+ if ((password = strupper_talloc(NULL, opt_password)) == NULL) {
+ DEBUG(0, ("strupper_talloc() failed!\n"));
exit(1);
}
- if (!convert_string_allocate(NULL, CH_UNIX,
- CH_DOS, password,
- strlen(password)+1,
- &lm_response.data,
- &lm_response.length, True)) {
- DEBUG(0, ("convert_string_allocate failed!\n"));
+ if (!convert_string_talloc(NULL, CH_UNIX,
+ CH_DOS, password,
+ strlen(password)+1,
+ &lm_response.data,
+ &lm_response.length, True)) {
+ DEBUG(0, ("convert_string_talloc failed!\n"));
exit(1);
}
- SAFE_FREE(password);
+ TALLOC_FREE(password);
switch (break_which) {
case BREAK_NONE:
@@ -513,8 +513,8 @@ static bool test_plaintext(enum ntlm_break break_which)
user_session_key,
&error_string, NULL);
- SAFE_FREE(nt_response.data);
- SAFE_FREE(lm_response.data);
+ TALLOC_FREE(nt_response.data);
+ TALLOC_FREE(lm_response.data);
data_blob_free(&chall);
if (!NT_STATUS_IS_OK(nt_status)) {
diff --git a/source3/web/cgi.c b/source3/web/cgi.c
index 40f9ee6966..261d4366bf 100644
--- a/source3/web/cgi.c
+++ b/source3/web/cgi.c
@@ -205,14 +205,14 @@ void cgi_load_variables(void)
char *dest = NULL;
size_t dest_len;
- convert_string_allocate(frame, CH_UTF8, CH_UNIX,
+ convert_string_talloc(frame, CH_UTF8, CH_UNIX,
variables[i].name, strlen(variables[i].name),
&dest, &dest_len, True);
SAFE_FREE(variables[i].name);
variables[i].name = SMB_STRDUP(dest ? dest : "");
dest = NULL;
- convert_string_allocate(frame, CH_UTF8, CH_UNIX,
+ convert_string_talloc(frame, CH_UTF8, CH_UNIX,
variables[i].value, strlen(variables[i].value),
&dest, &dest_len, True);
SAFE_FREE(variables[i].value);
diff --git a/source3/web/statuspage.c b/source3/web/statuspage.c
index 7dd1cf55cc..590be1dde2 100644
--- a/source3/web/statuspage.c
+++ b/source3/web/statuspage.c
@@ -171,10 +171,10 @@ static void print_share_mode(const struct share_mode_entry *e,
printf("NONE ");
printf("</td>");
- push_utf8_allocate(&utf8_fname, fname, &converted_size);
+ push_utf8_talloc(talloc_tos(), &utf8_fname, fname, &converted_size);
printf("<td>%s</td><td>%s</td></tr>\n",
utf8_fname,tstring(talloc_tos(),e->time.tv_sec));
- SAFE_FREE(utf8_fname);
+ TALLOC_FREE(utf8_fname);
}
diff --git a/source3/web/swat.c b/source3/web/swat.c
index 4bfb731814..1d843a0f65 100644
--- a/source3/web/swat.c
+++ b/source3/web/swat.c
@@ -255,16 +255,16 @@ static void show_parameter(int snum, struct parm_struct *parm)
for (;*list;list++) {
/* enclose in HTML encoded quotes if the string contains a space */
if ( strchr_m(*list, ' ') ) {
- push_utf8_allocate(&utf8_s1, *list, &converted_size);
- push_utf8_allocate(&utf8_s2, ((*(list+1))?", ":""), &converted_size);
+ push_utf8_talloc(talloc_tos(), &utf8_s1, *list, &converted_size);
+ push_utf8_talloc(talloc_tos(), &utf8_s2, ((*(list+1))?", ":""), &converted_size);
printf("&quot;%s&quot;%s", utf8_s1, utf8_s2);
} else {
- push_utf8_allocate(&utf8_s1, *list, &converted_size);
- push_utf8_allocate(&utf8_s2, ((*(list+1))?", ":""), &converted_size);
+ push_utf8_talloc(talloc_tos(), &utf8_s1, *list, &converted_size);
+ push_utf8_talloc(talloc_tos(), &utf8_s2, ((*(list+1))?", ":""), &converted_size);
printf("%s%s", utf8_s1, utf8_s2);
}
- SAFE_FREE(utf8_s1);
- SAFE_FREE(utf8_s2);
+ TALLOC_FREE(utf8_s1);
+ TALLOC_FREE(utf8_s2);
}
}
printf("\">");
@@ -285,10 +285,10 @@ static void show_parameter(int snum, struct parm_struct *parm)
case P_STRING:
case P_USTRING:
- push_utf8_allocate(&utf8_s1, *(char **)ptr, &converted_size);
+ push_utf8_talloc(talloc_tos(), &utf8_s1, *(char **)ptr, &converted_size);
printf("<input type=text size=40 name=\"parm_%s\" value=\"%s\">",
make_parm_name(parm->label), fix_quotes(ctx, utf8_s1));
- SAFE_FREE(utf8_s1);
+ TALLOC_FREE(utf8_s1);
printf("<input type=button value=\"%s\" onClick=\"swatform.parm_%s.value=\'%s\'\">",
_("Set Default"), make_parm_name(parm->label),fix_backslash((char *)(parm->def.svalue)));
break;
@@ -959,11 +959,11 @@ static void shares_page(void)
for (i=0;i<lp_numservices();i++) {
s = lp_servicename(i);
if (s && (*s) && strcmp(s,"IPC$") && !lp_print_ok(i)) {
- push_utf8_allocate(&utf8_s, s, &converted_size);
+ push_utf8_talloc(talloc_tos(), &utf8_s, s, &converted_size);
printf("<option %s value=\"%s\">%s\n",
(share && strcmp(share,s)==0)?"SELECTED":"",
utf8_s, utf8_s);
- SAFE_FREE(utf8_s);
+ TALLOC_FREE(utf8_s);
}
}
printf("</select></td>\n");