From 5d78635506907d61f63af2ce0f798b414333d0b5 Mon Sep 17 00:00:00 2001 From: Tyrolyean Date: Thu, 30 Apr 2020 21:22:06 +0200 Subject: [PATCH] Corrected boundary search behaviour Signed-off-by: Tyrolyean --- src/mail.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/mail.c b/src/mail.c index 4f3a02d..27a8e11 100644 --- a/src/mail.c +++ b/src/mail.c @@ -23,6 +23,7 @@ #include #include #include +#include int append_header(struct email_t* mail, const char* key, const char* value){ @@ -110,15 +111,23 @@ int remove_mail(struct email_t* mail){ } if(!found){ + fprintf(stderr, "Internal message not included in parent!\n"); return -1; } parent->submes_cnt--; /* Find the boundary that should come after our content */ + + char* boundary = malloc(parent->boundary_len+1); + memset(boundary, 0, parent->boundary_len+1); + memcpy(boundary,parent->boundary, parent->boundary_len); + char * after_boundary = - strstr(mail->message+mail->message_length, parent->boundary); + strstr(mail->message+mail->message_length, boundary); + free(boundary); if(after_boundary == NULL){ + fprintf(stderr, "Unable to find boundary!\n"); return -1; } const char * end = get_next_line(after_boundary,