Corrected boundary search behaviour

Signed-off-by: Tyrolyean <tyrolyean@tyrolyean.net>
This commit is contained in:
Tyrolyean 2020-04-30 21:22:06 +02:00
parent 0b2881ba90
commit 5d78635506
No known key found for this signature in database
GPG Key ID: 81EC9BAC5E9667C6
1 changed files with 10 additions and 1 deletions

View File

@ -23,6 +23,7 @@
#include <stddef.h>
#include <stdint.h>
#include <stdlib.h>
#include <stdio.h>
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,