Skip to content

Instantly share code, notes, and snippets.

@bagder
Created September 22, 2023 13:19
Show Gist options
  • Save bagder/81fb24ec9734fa60db1c6482d7b571c9 to your computer and use it in GitHub Desktop.
Save bagder/81fb24ec9734fa60db1c6482d7b571c9 to your computer and use it in GitHub Desktop.
formdata patch for 32 bit
diff --git a/lib/formdata.c b/lib/formdata.c
index 8984b6322..11b6f1687 100644
--- a/lib/formdata.c
+++ b/lib/formdata.c
@@ -787,10 +787,15 @@ static CURLcode setname(curl_mimepart *part, const char *name, size_t len)
res = curl_mime_name(part, zname);
free(zname);
return res;
}
+static int fake_fseek(FILE *stream, curl_off_t offset, int whence)
+{
+ return fseek(stream, (long)offset, whence);
+}
+
/*
* Curl_getformdata() converts a linked list of "meta data" into a mime
* structure. The input list is in 'post', while the output is stored in
* mime part at '*finalform'.
*
@@ -873,11 +878,11 @@ CURLcode Curl_getformdata(struct Curl_easy *data,
to result as expected. This feature has been kept for backward
compatibility: use of "-" pseudo file name should be avoided. */
result = curl_mime_data_cb(part, (curl_off_t) -1,
(curl_read_callback) fread,
CURLX_FUNCTION_CAST(curl_seek_callback,
- fseek),
+ fake_fseek),
NULL, (void *) stdin);
}
else
result = curl_mime_filedata(part, file->contents);
if(!result && (post->flags & HTTPPOST_READFILE))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment