From a78fd0cd5c88c35e2611cff4d937cbe00afa47e3 Mon Sep 17 00:00:00 2001 From: David Levine Date: Fri, 14 Mar 2014 20:25:06 -0500 Subject: [PATCH] Fixed some of the issues noted by clang --analyze with mhfixmsg.c and mkstemp.c. --- uip/mhfixmsg.c | 10 +++++++--- uip/mkstemp.c | 2 +- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/uip/mhfixmsg.c b/uip/mhfixmsg.c index f00fc97d..7fd69f50 100644 --- a/uip/mhfixmsg.c +++ b/uip/mhfixmsg.c @@ -563,10 +563,11 @@ get_multipart_boundary (CT ct, char **part_boundary) { while (begin >= (off_t) ct->c_begin) { fseeko (ct->c_fp, begin, SEEK_SET); while ((bytes_read = fread (buffer, 1, sizeof buffer, ct->c_fp)) > 0) { - char *end = buffer + bytes_read - 1; - char *cp; + char *cp = rfind_str (buffer, bytes_read, "--"); + + if (cp) { + char *end; - if ((cp = rfind_str (buffer, bytes_read, "--"))) { /* Trim off trailing "--" and anything beyond. */ *cp-- = '\0'; if ((end = rfind_str (buffer, cp - buffer, "\n"))) { @@ -1222,6 +1223,7 @@ build_multipart_alt (CT first_alt, CT new_part, int type, int subtype) { boundary_in_content (&new_part->c_cefile.ce_fp, new_part->c_cefile.ce_file, boundary)) == -1) { + free (ct); return NULL; } } @@ -1232,6 +1234,7 @@ build_multipart_alt (CT first_alt, CT new_part, int type, int subtype) { if ((found_boundary = boundary_in_content (&new_part->c_fp, new_part->c_file, boundary)) == -1) { + free (ct); return NULL; } } @@ -1252,6 +1255,7 @@ build_multipart_alt (CT first_alt, CT new_part, int type, int subtype) { if (found_boundary) { advise (NULL, "giving up trying to find a unique boundary"); + free (ct); return NULL; } } diff --git a/uip/mkstemp.c b/uip/mkstemp.c index d594c362..8139fec7 100644 --- a/uip/mkstemp.c +++ b/uip/mkstemp.c @@ -104,7 +104,7 @@ build_template(const char *directory, const char *prefix, const char *suffix) { tp += sizeof pattern - 1; (void) strncpy(tp, suffix, suffix_len); - tp += suffix_len; + /* tp += suffix_len; */ template[len-1] = '\0'; -- 2.56.0