1.1 --- a/src/etpan_mime.c Sun Mar 29 12:03:09 2015 +0200
1.2 +++ b/src/etpan_mime.c Sun Mar 29 13:54:38 2015 +0200
1.3 @@ -8,9 +8,7 @@
1.4 #include <string.h>
1.5 #include <stdlib.h>
1.6 #include <assert.h>
1.7 -
1.8 -
1.9 -time_t mail_mkgmtime(struct tm * tmp);
1.10 +#include <errno.h>
1.11
1.12 #define MAX_MESSAGE_ID 512
1.13
1.14 @@ -630,7 +628,7 @@
1.15 return NULL;
1.16 }
1.17
1.18 -bool parameter_has_value(
1.19 +static bool parameter_has_value(
1.20 struct mailmime_content *content,
1.21 const char *name,
1.22 const char *value
1.23 @@ -712,8 +710,10 @@
1.24
1.25 assert(content);
1.26
1.27 - if (content->ct_subtype == NULL)
1.28 + if (content->ct_subtype == NULL) {
1.29 + errno = EINVAL;
1.30 return NULL;
1.31 + }
1.32
1.33 if (content->ct_type && content->ct_type->tp_data.tp_discrete_type) {
1.34 size_t len;
1.35 @@ -739,23 +739,27 @@
1.36 _type = "extension";
1.37 break;
1.38 default:
1.39 + errno = EINVAL;
1.40 return NULL;
1.41 }
1.42
1.43 len = strlen(_type) + 1 + strlen(content->ct_subtype) + 1;
1.44 type = calloc(1, len);
1.45 assert(type);
1.46 - // BUG: out of memory cannot be signaled
1.47 - if (type == NULL)
1.48 + if (type == NULL) {
1.49 + errno = ENOMEM;
1.50 return NULL;
1.51 + }
1.52
1.53 strcpy(type, _type);
1.54 strcat(type, "/");
1.55 strcat(type, content->ct_subtype);
1.56
1.57 + errno = 0;
1.58 return type;
1.59 }
1.60
1.61 + errno = EINVAL;
1.62 return NULL;
1.63 }
1.64
2.1 --- a/src/etpan_mime.h Sun Mar 29 12:03:09 2015 +0200
2.2 +++ b/src/etpan_mime.h Sun Mar 29 13:54:38 2015 +0200
2.3 @@ -68,13 +68,6 @@
2.4 clist * _get_fields(struct mailmime * mime);
2.5 struct mailmime_content * _get_content(struct mailmime * mime);
2.6 char * _get_filename(struct mailmime *mime);
2.7 -
2.8 -bool parameter_has_value(
2.9 - struct mailmime_content *content,
2.10 - const char *name,
2.11 - const char *value
2.12 - );
2.13 -
2.14 bool _is_multipart(struct mailmime_content *content, const char *subtype);
2.15 bool _is_PGP_MIME(struct mailmime_content *content);
2.16 bool _is_text_part(struct mailmime_content *content, const char *subtype);
3.1 --- a/src/mime.c Sun Mar 29 12:03:09 2015 +0200
3.2 +++ b/src/mime.c Sun Mar 29 13:54:38 2015 +0200
3.3 @@ -1300,13 +1300,21 @@
3.4 }
3.5 else {
3.6 char *data = NULL;
3.7 - size_t size;
3.8 - char * mime_type = NULL;
3.9 - char * filename = NULL;
3.10 + size_t size = 0;
3.11 + char * mime_type;
3.12 + char * filename;
3.13
3.14 mime_type = _get_content_type(content);
3.15 - if (mime_type == NULL)
3.16 - return PEP_ILLEGAL_VALUE;
3.17 + if (mime_type == NULL) {
3.18 + switch (errno) {
3.19 + case EINVAL:
3.20 + return PEP_ILLEGAL_VALUE;
3.21 + case ENOMEM:
3.22 + return PEP_OUT_OF_MEMORY;
3.23 + default:
3.24 + return PEP_UNKNOWN_ERROR;
3.25 + }
3.26 + }
3.27
3.28 status = interpret_body(mime, &data, &size);
3.29 if (status)