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"))) {
boundary_in_content (&new_part->c_cefile.ce_fp,
new_part->c_cefile.ce_file,
boundary)) == -1) {
+ free (ct);
return NULL;
}
}
if ((found_boundary = boundary_in_content (&new_part->c_fp,
new_part->c_file,
boundary)) == -1) {
+ free (ct);
return NULL;
}
}
if (found_boundary) {
advise (NULL, "giving up trying to find a unique boundary");
+ free (ct);
return NULL;
}
}
tp += sizeof pattern - 1;
(void) strncpy(tp, suffix, suffix_len);
- tp += suffix_len;
+ /* tp += suffix_len; */
template[len-1] = '\0';