]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
mime: use a define instead of the magic number 24
authorDaniel Stenberg <daniel@haxx.se>
Fri, 11 Feb 2022 22:21:38 +0000 (23:21 +0100)
committerDaniel Stenberg <daniel@haxx.se>
Sun, 13 Feb 2022 10:46:18 +0000 (11:46 +0100)
MIME_BOUNDARY_DASHES is now the number of leading dashes in the
generated boundary string.

Closes #8441

lib/mime.c
lib/mime.h

index aba9e76838366fd4d6f4e510d27ec6e7001f99a4..cab3ef1c378ef2a39d16cf87838dd558a7a5815d 100644 (file)
@@ -1284,8 +1284,9 @@ curl_mime *curl_mime_init(struct Curl_easy *easy)
     mime->firstpart = NULL;
     mime->lastpart = NULL;
 
-    memset(mime->boundary, '-', 24);
-    if(Curl_rand_hex(easy, (unsigned char *) &mime->boundary[24],
+    memset(mime->boundary, '-', MIME_BOUNDARY_DASHES);
+    if(Curl_rand_hex(easy,
+                     (unsigned char *) &mime->boundary[MIME_BOUNDARY_DASHES],
                      MIME_RAND_BOUNDARY_CHARS + 1)) {
       /* failed to get random separator, bail out */
       free(mime);
index 9e62785649ce4a94f30968bbec29e96a9515ecbb..f2fc434c58fb0c435ddf813a37c97332832ca642 100644 (file)
@@ -24,6 +24,7 @@
 
 #include "curl_setup.h"
 
+#define MIME_BOUNDARY_DASHES            24  /* leading boundary dashes */
 #define MIME_RAND_BOUNDARY_CHARS        16  /* Nb. of random boundary chars. */
 #define MAX_ENCODED_LINE_LENGTH         76  /* Maximum encoded line length. */
 #define ENCODING_BUFFER_SIZE            256 /* Encoding temp buffers size. */
@@ -92,7 +93,7 @@ struct mime_state {
 };
 
 /* Boundary string length. */
-#define MIME_BOUNDARY_LEN (24 + MIME_RAND_BOUNDARY_CHARS)
+#define MIME_BOUNDARY_LEN (MIME_BOUNDARY_DASHES + MIME_RAND_BOUNDARY_CHARS)
 
 /* A mime multipart. */
 struct curl_mime {