]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
CLEANUP: chunk: remove misleading chunk_strncat() function
authorWilly Tarreau <w@1wt.eu>
Mon, 8 Nov 2021 10:44:47 +0000 (11:44 +0100)
committerWilly Tarreau <w@1wt.eu>
Mon, 8 Nov 2021 11:08:26 +0000 (12:08 +0100)
This function claims to perform an strncat()-like operation but it does
not, it always copies the indicated number of bytes, regardless of the
presence of a NUL character (what is currently done by chunk_memcat()).
Let's remove it and explicitly replace it with chunk_memcat().

include/haproxy/chunk.h
src/cache.c

index 05fd161217006119aab0304625689940851adae1..b5d515170e7a8735af6de187609f0888072f07d4 100644 (file)
@@ -203,14 +203,6 @@ static inline int chunk_strcat(struct buffer *chk, const char *str)
        return 1;
 }
 
-/* appends <nb> characters from str after <chk>.
- * Returns 0 in case of failure.
- */
-static inline int chunk_strncat(struct buffer *chk, const char *str, int nb)
-{
-       return chunk_memcat(chk, str, nb);
-}
-
 /* Adds a trailing zero to the current chunk and returns the pointer to the
  * following part. The purpose is to be able to use a chunk as a series of
  * short independent strings with chunk_* functions, which do not need to be
index ee42947c12d418d92ceee39812ebbc95d3968cd2..9c108ae5370ba767a6e05ece9a29bfc320a0855a 100644 (file)
@@ -779,8 +779,8 @@ int http_calc_maxage(struct stream *s, struct cache *cache, int *true_maxage)
                if (value) {
                        struct buffer *chk = get_trash_chunk();
 
-                       chunk_strncat(chk, value, ctx.value.len - 8 + 1);
-                       chunk_strncat(chk, "", 1);
+                       chunk_memcat(chk, value, ctx.value.len - 8 + 1);
+                       chunk_memcat(chk, "", 1);
                        offset = (*chk->area == '"') ? 1 : 0;
                        smaxage = strtol(chk->area + offset, &endptr, 10);
                        if (unlikely(smaxage < 0 || endptr == chk->area))
@@ -791,8 +791,8 @@ int http_calc_maxage(struct stream *s, struct cache *cache, int *true_maxage)
                if (value) {
                        struct buffer *chk = get_trash_chunk();
 
-                       chunk_strncat(chk, value, ctx.value.len - 7 + 1);
-                       chunk_strncat(chk, "", 1);
+                       chunk_memcat(chk, value, ctx.value.len - 7 + 1);
+                       chunk_memcat(chk, "", 1);
                        offset = (*chk->area == '"') ? 1 : 0;
                        maxage = strtol(chk->area + offset, &endptr, 10);
                        if (unlikely(maxage < 0 || endptr == chk->area))