Skip to content

Commit

Permalink
apr_escape_entity(): Don't truncate the final ';' in hex entities.
Browse files Browse the repository at this point in the history
apr_snprintf() takes the buffer size (include NUL), and can by used with
NULL/zero-size buffer to determine the output length.



git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1916390 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
ylavic committed Mar 18, 2024
1 parent 296cefa commit 4578be2
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions encoding/apr_escape.c
Original file line number Diff line number Diff line change
Expand Up @@ -571,7 +571,7 @@ APR_DECLARE(apr_status_t) apr_escape_entity(char *escaped, const char *str,
found = 1;
}
else if (toasc && !apr_isascii(c)) {
int offset = apr_snprintf((char *) d, 6, "&#%3.3d;", c);
int offset = apr_snprintf((char *) d, 7, "&#%3.3d;", c);
size += offset;
d += offset;
found = 1;
Expand Down Expand Up @@ -613,8 +613,7 @@ APR_DECLARE(apr_status_t) apr_escape_entity(char *escaped, const char *str,
found = 1;
}
else if (toasc && !apr_isascii(c)) {
char buf[8];
size += apr_snprintf(buf, 6, "&#%3.3d;", c);
size += apr_snprintf(NULL, 0, "&#%3.3d;", c);
found = 1;
}
else {
Expand Down

0 comments on commit 4578be2

Please sign in to comment.