diff --git a/include/haproxy/tools.h b/include/haproxy/tools.h index 3726f6353..d76b2d13c 100644 --- a/include/haproxy/tools.h +++ b/include/haproxy/tools.h @@ -399,11 +399,11 @@ int addr_is_local(const struct netns_entry *ns, * with the hexadecimal representation of their ASCII-code (2 digits) * prefixed by , and will store the result between (included) * and (excluded), and will always terminate the string with a '\0' - * before . The position of the '\0' is returned if the conversion - * completes. If bytes are missing between and , then the - * conversion will be incomplete and truncated. If <= , the '\0' - * cannot even be stored so we return without writing the 0. + * before . If bytes are missing between and , then the + * conversion will be incomplete and truncated. * The input string must also be zero-terminated. + * + * Return the address of the \0 character, or NULL on error */ extern const char hextab[]; extern long query_encode_map[]; @@ -424,8 +424,9 @@ char *encode_chunk(char *start, char *stop, * is reached or NULL-byte is encountered. The result will * be stored between (included) and (excluded). This * function will always try to terminate the resulting string with a '\0' - * before , and will return its position if the conversion - * completes. + * before . + * + * Return the address of the \0 character, or NULL on error */ char *escape_string(char *start, char *stop, const char escape, const long *map, diff --git a/src/log.c b/src/log.c index a1236e9f2..847706d2c 100644 --- a/src/log.c +++ b/src/log.c @@ -1734,6 +1734,8 @@ int get_log_facility(const char *fac) * When using the +E log format option, it will try to escape '"\]' * characters with '\' as prefix. The same prefix should not be used as * . + * + * Return the address of the \0 character, or NULL on error */ static char *lf_encode_string(char *start, char *stop, const char escape, const long *map, @@ -1764,13 +1766,14 @@ static char *lf_encode_string(char *start, char *stop, string++; } *start = '\0'; + return start; } } else { return encode_string(start, stop, escape, map, string); } - return start; + return NULL; } /* @@ -1779,6 +1782,8 @@ static char *lf_encode_string(char *start, char *stop, * When using the +E log format option, it will try to escape '"\]' * characters with '\' as prefix. The same prefix should not be used as * . + * + * Return the address of the \0 character, or NULL on error */ static char *lf_encode_chunk(char *start, char *stop, const char escape, const long *map, @@ -1814,13 +1819,14 @@ static char *lf_encode_chunk(char *start, char *stop, str++; } *start = '\0'; + return start; } } else { return encode_chunk(start, stop, escape, map, chunk); } - return start; + return NULL; } /* diff --git a/src/tools.c b/src/tools.c index 475922283..b08fb18ce 100644 --- a/src/tools.c +++ b/src/tools.c @@ -1969,11 +1969,11 @@ int addr_is_local(const struct netns_entry *ns, * with the hexadecimal representation of their ASCII-code (2 digits) * prefixed by , and will store the result between (included) * and (excluded), and will always terminate the string with a '\0' - * before . The position of the '\0' is returned if the conversion - * completes. If bytes are missing between and , then the - * conversion will be incomplete and truncated. If <= , the '\0' - * cannot even be stored so we return without writing the 0. + * before . If bytes are missing between and , then the + * conversion will be incomplete and truncated. * The input string must also be zero-terminated. + * + * Return the address of the \0 character, or NULL on error */ const char hextab[16] = "0123456789ABCDEF"; char *encode_string(char *start, char *stop, @@ -1995,8 +1995,9 @@ char *encode_string(char *start, char *stop, string++; } *start = '\0'; + return start; } - return start; + return NULL; } /* @@ -2025,8 +2026,9 @@ char *encode_chunk(char *start, char *stop, str++; } *start = '\0'; + return start; } - return start; + return NULL; } /* @@ -2035,8 +2037,9 @@ char *encode_chunk(char *start, char *stop, * is reached or NULL-byte is encountered. The result will * be stored between (included) and (excluded). This * function will always try to terminate the resulting string with a '\0' - * before , and will return its position if the conversion - * completes. + * before . + * + * Return the address of the \0 character, or NULL on error */ char *escape_string(char *start, char *stop, const char escape, const long *map, @@ -2056,8 +2059,9 @@ char *escape_string(char *start, char *stop, string++; } *start = '\0'; + return start; } - return start; + return NULL; } /* Check a string for using it in a CSV output format. If the string contains