Resized mail message body to allow resize
Signed-off-by: Tyrolyean <tyrolyean@tyrolyean.net>
This commit is contained in:
parent
2a69e3d104
commit
0e9980154d
2 changed files with 21 additions and 3 deletions
|
@ -66,7 +66,7 @@ void redetect_body_head(struct email_t* mail){
|
|||
}
|
||||
|
||||
mail->body_offset = body_start - mail->message;
|
||||
mail->header_len = last_lf - mail->message;
|
||||
mail->header_len = last_lf - mail->message - 1 /* for the CR */;
|
||||
return;
|
||||
|
||||
|
||||
|
|
22
src/main.c
22
src/main.c
|
@ -92,6 +92,24 @@ void receive_mail(struct mail_recv_t* rec){
|
|||
size_t body_len = rec->body_p-
|
||||
(rec->input_buffer+rec->body_offs);
|
||||
|
||||
/* Copy the after body message and reduce original
|
||||
* pointer to mail size to allow reallocs */
|
||||
size_t abody_len = rec->in_len-
|
||||
(rec->body_offs+body_len);
|
||||
|
||||
void * abody = malloc(abody_len);
|
||||
memcpy(abody,
|
||||
rec->input_buffer+rec->body_offs+body_len,
|
||||
abody_len);
|
||||
|
||||
/* reduce the input buffer to the body */
|
||||
memmove(rec->input_buffer,
|
||||
rec->input_buffer+rec->body_offs, body_len);
|
||||
rec->input_buffer = realloc(rec->input_buffer,
|
||||
body_len + 1);
|
||||
rec->input_buffer[body_len+1] = 0;
|
||||
rec->in_len = body_len;
|
||||
|
||||
char* new_body = attach_files(
|
||||
rec->input_buffer+rec->body_offs,
|
||||
body_len);
|
||||
|
@ -112,8 +130,8 @@ void receive_mail(struct mail_recv_t* rec){
|
|||
/* Rest of conversation after message */
|
||||
|
||||
write((rec->fds[1].fd),
|
||||
rec->input_buffer+rec->body_offs+body_len,
|
||||
rec->in_len-(rec->body_offs+body_len));
|
||||
abody,
|
||||
abody_len);
|
||||
|
||||
rec->after_body = true;
|
||||
|
||||
|
|
Loading…
Reference in a new issue