summaryrefslogtreecommitdiffstats
path: root/copy.c
diff options
context:
space:
mode:
authorKevin McCarthy <kevin@8t8.us>2022-04-09 13:32:33 -0700
committerKevin McCarthy <kevin@8t8.us>2022-04-12 11:07:34 -0700
commitf82641352c6c0f1912c518875133a9b73a0e1f34 (patch)
tree9261b92befb8c51cb8be4665fe14293baa0ab457 /copy.c
parent195bcad02535738e03788e34cdc3f1f0c842b6e1 (diff)
Fix strlen() assigns to be of type size_t where obvious.
Ticket 405 had an almost-exploit enabled by sloppy assignment of strlen(). There were more details involved, of course, but this served as encouragement to clean up obvious "strlen assignment to int" in the rest of the code. Note this is not *all* cases, only those that were simple and obvious. In some cases, the code assigns strlen() to an int but also uses that variable to hold negative values for another reason. In other cases, an API is involved (e.g. SASL) that make changing potentially dangerous. And lastly, some functions were just a bit too complicated to risk introducing a bug.
Diffstat (limited to 'copy.c')
-rw-r--r--copy.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/copy.c b/copy.c
index de378692..417043fd 100644
--- a/copy.c
+++ b/copy.c
@@ -171,7 +171,7 @@ mutt_copy_hdr (FILE *in, FILE *out, LOFF_T off_start, LOFF_T off_end, int flags,
headers[x] = this_one;
else
{
- int hlen = mutt_strlen (headers[x]);
+ size_t hlen = mutt_strlen (headers[x]);
safe_realloc (&headers[x], hlen + this_one_len + sizeof (char));
strcat (headers[x] + hlen, this_one); /* __STRCAT_CHECKED__ */
@@ -264,7 +264,7 @@ mutt_copy_hdr (FILE *in, FILE *out, LOFF_T off_start, LOFF_T off_end, int flags,
}
else
{
- int blen = mutt_strlen (buf);
+ size_t blen = mutt_strlen (buf);
safe_realloc (&this_one, this_one_len + blen + sizeof (char));
strcat (this_one + this_one_len, buf); /* __STRCAT_CHECKED__ */
@@ -287,7 +287,7 @@ mutt_copy_hdr (FILE *in, FILE *out, LOFF_T off_start, LOFF_T off_end, int flags,
headers[x] = this_one;
else
{
- int hlen = mutt_strlen (headers[x]);
+ size_t hlen = mutt_strlen (headers[x]);
safe_realloc (&headers[x], hlen + this_one_len + sizeof (char));
strcat (headers[x] + hlen, this_one); /* __STRCAT_CHECKED__ */