Corrected behaviour for boundary deletion

Signed-off-by: Tyrolyean <tyrolyean@tyrolyean.net>
This commit is contained in:
Tyrolyean 2020-04-30 21:41:14 +02:00
parent 5d78635506
commit 0aa030735f
No known key found for this signature in database
GPG key ID: 81EC9BAC5E9667C6

View file

@ -98,11 +98,16 @@ int remove_mail(struct email_t* mail){
struct email_t* parent = mail->parent; struct email_t* parent = mail->parent;
bool found = false; bool found = false;
struct email_t * followup = NULL;
for(size_t i = 0; i < parent->submes_cnt; i++){ for(size_t i = 0; i < parent->submes_cnt; i++){
if(parent->submes[i] == mail){ if(parent->submes[i] == mail){
/* Remove ourselfs from the parent */ /* Remove ourselfs from the parent */
found = true; found = true;
if(i+1 < parent->submes_cnt){
followup = parent->submes[i+1];
}
} }
if(found && (i+1 < parent->submes_cnt)){ if(found && (i+1 < parent->submes_cnt)){
@ -116,24 +121,11 @@ int remove_mail(struct email_t* mail){
} }
parent->submes_cnt--; parent->submes_cnt--;
char* end = NULL;
/* Find the boundary that should come after our content */ if(followup == NULL){
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, boundary);
free(boundary);
if(after_boundary == NULL){
fprintf(stderr, "Unable to find boundary!\n");
return -1;
}
const char * end = get_next_line(after_boundary,
parent->message_length-(after_boundary - parent->message));
if(end == NULL){
end = parent->message + parent->message_length; end = parent->message + parent->message_length;
}else{
end = followup->message - 1;
} }
size_t remove_len = mail->message - end; size_t remove_len = mail->message - end;