src/etpan_mime.c
changeset 116 e4d286e7b300
parent 115 cab016770f6f
child 125 5119178815d8
     1.1 --- a/src/etpan_mime.c	Sun Mar 15 14:21:29 2015 +0100
     1.2 +++ b/src/etpan_mime.c	Sun Mar 15 19:39:07 2015 +0100
     1.3 @@ -12,29 +12,24 @@
     1.4  
     1.5  #define MAX_MESSAGE_ID 512
     1.6  
     1.7 -static char * generate_boundary(const char * boundary_prefix)
     1.8 +static char * generate_boundary(void)
     1.9  {
    1.10      char id[MAX_MESSAGE_ID];
    1.11 -    time_t now;
    1.12 -    char name[MAX_MESSAGE_ID];
    1.13 -    long value;
    1.14 +    long value1;
    1.15 +    long value2;
    1.16 +    long value3;
    1.17 +    long value4;
    1.18      int r;
    1.19   
    1.20 -    id[MAX_MESSAGE_ID - 1] = 0;
    1.21 -    name[MAX_MESSAGE_ID - 1] = 0;
    1.22 -
    1.23 -    now = time(NULL);
    1.24 +    // no random needed here
    1.25  
    1.26 -    value = random();
    1.27 -    r = gethostname(name, MAX_MESSAGE_ID - 1);
    1.28 -    if (r == -1)
    1.29 -        return NULL;
    1.30 -    
    1.31 -    if (boundary_prefix == NULL)
    1.32 -        boundary_prefix = "";
    1.33 -    
    1.34 -    snprintf(id, MAX_MESSAGE_ID, "%s%lx_%lx_%x", boundary_prefix, now, value,
    1.35 -            getpid());
    1.36 +    value1 = random();
    1.37 +    value2 = random();
    1.38 +    value3 = random();
    1.39 +    value4 = random();
    1.40 +
    1.41 +    snprintf(id, MAX_MESSAGE_ID, "%.4lx%.4lx%.4lx%.4lx", value1, value2,
    1.42 +            value3, value4);
    1.43      
    1.44      return strdup(id);
    1.45  }
    1.46 @@ -42,7 +37,6 @@
    1.47  struct mailmime * part_new_empty(
    1.48          struct mailmime_content * content,
    1.49          struct mailmime_fields * mime_fields,
    1.50 -        const char * boundary_prefix,
    1.51          int force_single
    1.52      )
    1.53  {
    1.54 @@ -54,8 +48,7 @@
    1.55      char * attr_value = NULL;
    1.56      struct mailmime_parameter * param = NULL;
    1.57      clist * parameters = NULL;
    1.58 -    char * boundary = NULL;
    1.59 -
    1.60 +    char *boundary = NULL;
    1.61  
    1.62  	list = NULL;
    1.63  
    1.64 @@ -102,7 +95,7 @@
    1.65          if (attr_name == NULL)
    1.66              goto enomem;
    1.67  
    1.68 -		boundary = generate_boundary(boundary_prefix);
    1.69 +		boundary = generate_boundary();
    1.70          assert(boundary);
    1.71  		attr_value = boundary;
    1.72  		if (attr_value == NULL)
    1.73 @@ -168,7 +161,7 @@
    1.74      if (mime_fields == NULL)
    1.75          goto enomem;
    1.76  
    1.77 -	mime = part_new_empty(content, mime_fields, NULL, 1);
    1.78 +	mime = part_new_empty(content, mime_fields, 1);
    1.79      if (mime == NULL)
    1.80          goto enomem;
    1.81      mime_fields = NULL;
    1.82 @@ -245,7 +238,7 @@
    1.83              goto enomem;
    1.84      }
    1.85  
    1.86 -	mime = part_new_empty(content, mime_fields, NULL, 1);
    1.87 +	mime = part_new_empty(content, mime_fields, 1);
    1.88      if (mime == NULL)
    1.89          goto enomem;
    1.90      content = NULL;
    1.91 @@ -322,7 +315,7 @@
    1.92      encoding = NULL;
    1.93      disposition = NULL;
    1.94  
    1.95 -    mime = part_new_empty(content, mime_fields, NULL, 1);
    1.96 +    mime = part_new_empty(content, mime_fields, 1);
    1.97      if (mime == NULL)
    1.98          goto enomem;
    1.99      content = NULL;
   1.100 @@ -350,10 +343,7 @@
   1.101      return NULL;
   1.102  }
   1.103  
   1.104 -struct mailmime * part_multiple_new(
   1.105 -        const char * type,
   1.106 -        const char * boundary_prefix
   1.107 -    )
   1.108 +struct mailmime * part_multiple_new(const char *type)
   1.109  {
   1.110      struct mailmime_fields *mime_fields = NULL;
   1.111      struct mailmime_content *content = NULL;
   1.112 @@ -367,7 +357,7 @@
   1.113      if (content == NULL)
   1.114          goto enomem;
   1.115      
   1.116 -    mp = part_new_empty(content, mime_fields, boundary_prefix, 0);
   1.117 +    mp = part_new_empty(content, mime_fields, 0);
   1.118      if (mp == NULL)
   1.119          goto enomem;
   1.120