X-Git-Url: https://diplodocus.org/git/nmh/blobdiff_plain/177f020f122827214159c46dcfe7ded1e3c8d1c3..c576ad2674c37a1c63f004c71049998f38854c64:/sbr/escape_addresses.c diff --git a/sbr/escape_addresses.c b/sbr/escape_addresses.c index 0d898dbd..05c6f936 100644 --- a/sbr/escape_addresses.c +++ b/sbr/escape_addresses.c @@ -5,11 +5,10 @@ * complete copyright information. */ -#include +#include #include -static void -escape_component (char *name, size_t namesize, char *chars); +static void escape_component (char *name, size_t namesize, char *chars); void @@ -33,7 +32,7 @@ escape_local_part (char *name, size_t namesize) { argument is modified in place. Its size is specified by the namesize argument. The need_escape argument is a string of characters that require that name be escaped. */ -void +static void escape_component (char *name, size_t namesize, char *chars_to_escape) { /* If name contains any chars_to_escape: 1) enclose it in "" @@ -42,7 +41,7 @@ escape_component (char *name, size_t namesize, char *chars_to_escape) { if (strpbrk(name, chars_to_escape)) { char *destp, *srcp; /* Maximum space requirement would be if each character had - to be escaped, plus enclosing double quotes, plus null termintor. + to be escaped, plus enclosing double quotes, plus NUL terminator. E.g., 2 characters, "", would require 7, "\"\""0, where that 0 is '\0'. */ char *tmp = mh_xmalloc (2*strlen(name) + 3); @@ -76,7 +75,7 @@ escape_component (char *name, size_t namesize, char *chars_to_escape) { if (strcmp (tmp, "\"")) { size_t len = destp - tmp; assert ((ssize_t) strlen(tmp) + 1 == destp - tmp); - strncpy (name, tmp, len <= namesize ? len : namesize); + strncpy (name, tmp, min(len, namesize)); } else { /* Handle just " as special case here instead of above. */ strncpy (name, "\"\\\"\"", namesize);