diff options
author | Daniel Stenberg <daniel@haxx.se> | 2022-02-11 23:21:38 +0100 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2022-02-13 11:46:18 +0100 |
commit | c8e8791d2d6ed05ac9f7d26869a1c2c606b11f40 (patch) | |
tree | 469fd344d847cc6452d4233ff8aee1e6c0a7c049 | |
parent | 65c6e37fe3f53db13501f7586b1b4ba9bfe1d6d5 (diff) | |
download | curl-c8e8791d2d6ed05ac9f7d26869a1c2c606b11f40.tar.gz |
mime: use a define instead of the magic number 24
MIME_BOUNDARY_DASHES is now the number of leading dashes in the
generated boundary string.
Closes #8441
-rw-r--r-- | lib/mime.c | 5 | ||||
-rw-r--r-- | lib/mime.h | 3 |
2 files changed, 5 insertions, 3 deletions
diff --git a/lib/mime.c b/lib/mime.c index aba9e7683..cab3ef1c3 100644 --- a/lib/mime.c +++ b/lib/mime.c @@ -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); diff --git a/lib/mime.h b/lib/mime.h index 9e6278564..f2fc434c5 100644 --- a/lib/mime.h +++ b/lib/mime.h @@ -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 { |