]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
s/talloc_realloc_bstr/talloc_bstr_realloc/g
authorArran Cudbard-Bell <a.cudbardb@freeradius.org>
Sat, 23 Mar 2019 15:41:40 +0000 (22:41 +0700)
committerArran Cudbard-Bell <a.cudbardb@freeradius.org>
Sat, 23 Mar 2019 15:41:40 +0000 (22:41 +0700)
src/lib/server/cf_util.c
src/lib/server/xlat_eval.c
src/lib/server/xlat_tokenize.c
src/lib/util/regex.c
src/lib/util/talloc.c
src/lib/util/talloc.h
src/modules/rlm_cipher/rlm_cipher.c

index e13dc1053b45cc93ca29862226e43814aef9c16e..52fac5dbcd18a1c53c0fa7f09ebb7e372fd00d14 100644 (file)
@@ -1752,7 +1752,7 @@ int cf_pair_in_table(int32_t *out, FR_NAME_NUMBER const *table, CONF_PAIR *cp)
        /*
         *      Trim the final ", "
         */
-       MEM(list = talloc_realloc_bstr(NULL, list, talloc_array_length(list) - 3));
+       MEM(list = talloc_bstr_realloc(NULL, list, talloc_array_length(list) - 3));
 
        cf_log_err(cp, "Invalid value \"%s\". Expected one of %s", cf_pair_value(cp), list);
 
index 7283cb471f7e5ddba8e713ccbfda0b160e828bc2..44eab60a83b5941db293c02a3e303c08b10773a3 100644 (file)
@@ -798,7 +798,7 @@ xlat_action_t xlat_frame_eval_repeat(TALLOC_CTX *ctx, fr_cursor_t *out,
                         *      Shrink the buffer
                         */
                        if ((node->xlat->buf_len > 0) && (slen > 0)) {
-                               MEM(str = talloc_realloc_bstr(ctx, str, (size_t)slen));
+                               MEM(str = talloc_bstr_realloc(ctx, str, (size_t)slen));
                        }
 
                        /*
index 9447b646641920cf0a40f60330075f2e09c61a68..c95f68468008952df951890e46a24ce6a60e7be5 100644 (file)
@@ -685,7 +685,7 @@ static ssize_t xlat_tokenize_literal(TALLOC_CTX *ctx, xlat_exp_t **head, char co
        /*
         *      Shrink the buffer to the right size
         */
-       MEM(start = talloc_realloc_bstr(ctx, start, node->len));
+       MEM(start = talloc_bstr_realloc(ctx, start, node->len));
        node->fmt = start;
 
        return p - fmt;
index 4292b1d6506f4e637a77182ed0ebf1970901978d..55d2325e574455b8262d4053727e94e03a62f38d 100644 (file)
@@ -503,7 +503,7 @@ again:
         *      ...and as pcre2_substitute just succeeded actual_len does not include \0.
         */
        if (actual_len < (buff_len - 1)) {
-               buff = talloc_realloc_bstr(ctx, buff, actual_len);
+               buff = talloc_bstr_realloc(ctx, buff, actual_len);
                if (!buff) {
                        fr_strerror_printf("reallocing pcre2_substitute result buffer failed");
                        return -1;
index 0f650c5435d787e7d8ffe69f5559edd02458a359..431bd545b8448b7b10057c2d141f3575a0621e52 100644 (file)
@@ -352,16 +352,23 @@ char *talloc_bstr_append(TALLOC_CTX *ctx, char *to, char const *from, size_t fro
  *
  * @param[in] ctx      to realloc buffer into.
  * @param[in] in       string to trim.  Will be invalid after
- *                     this function returns.
+ *                     this function returns. If NULL a new zero terminated
+ *                     buffer of inlen bytes will be allocated.
  * @param[in] inlen    Length to trim string to.
  * @return
  *     - The realloced string on success.  in then points to invalid memory.
  *     - NULL on failure. In will still be valid.
  */
-char *talloc_realloc_bstr(TALLOC_CTX *ctx, char *in, size_t inlen)
+char *talloc_bstr_realloc(TALLOC_CTX *ctx, char *in, size_t inlen)
 {
        char *n;
 
+       if (!in) {
+               n = talloc_array(ctx, char, inlen);
+               n[0] = '\0';
+               return n;
+       }
+
        n = talloc_realloc_size(ctx, in, inlen + 1);
        if (!n) return NULL;
 
index 1cf9f3b4571f17f6a4a27139495d62129710329c..e616934fa8b02a139a5553f306fa9aff492909cd 100644 (file)
@@ -52,7 +52,7 @@ char          *talloc_bstrndup(TALLOC_CTX *ctx, char const *in, size_t inlen);
 
 char           *talloc_bstr_append(TALLOC_CTX *ctx, char *to, char const *from, size_t from_len);
 
-char           *talloc_realloc_bstr(TALLOC_CTX *ctx, char *in, size_t inlen);
+char           *talloc_bstr_realloc(TALLOC_CTX *ctx, char *in, size_t inlen);
 
 char           *talloc_buffer_append_buffer(TALLOC_CTX *ctx, char *to, char const *from);
 
index 90ae9935d7ce67255dc9fa5198975fb72b7a423e..0629b7fa24bfb7771941ea85fb8e710ce00183b6 100644 (file)
@@ -674,7 +674,7 @@ static xlat_action_t cipher_rsa_decrypt_xlat(TALLOC_CTX *ctx, fr_cursor_t *out,
        {
                char *n;
 
-               n = talloc_realloc_bstr(ctx, plaintext, plaintext_len);
+               n = talloc_bstr_realloc(ctx, plaintext, plaintext_len);
                if (unlikely(!n)) {
                        REDEBUG("Failed shrinking plaintext buffer");
                        talloc_free(plaintext);