[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] [gnurl] 129/256: mime: fix some implicit curl_off_t --> siz
From: |
gnunet |
Subject: |
[GNUnet-SVN] [gnurl] 129/256: mime: fix some implicit curl_off_t --> size_t conversion warnings. |
Date: |
Fri, 06 Oct 2017 19:43:40 +0200 |
This is an automated email from the git hooks/post-receive script.
ng0 pushed a commit to branch master
in repository gnurl.
commit 045b076ae8362006f6977a80e6a5e3ef0eb903eb
Author: Patrick Monnerat <address@hidden>
AuthorDate: Sun Sep 3 10:18:58 2017 +0100
mime: fix some implicit curl_off_t --> size_t conversion warnings.
---
lib/mime.c | 4 ++--
src/tool_setopt.c | 12 ++++++++----
2 files changed, 10 insertions(+), 6 deletions(-)
diff --git a/lib/mime.c b/lib/mime.c
index 759ade085..11d387d62 100644
--- a/lib/mime.c
+++ b/lib/mime.c
@@ -282,7 +282,7 @@ static size_t mime_mem_read(char *buffer, size_t size,
size_t nitems,
void *instream)
{
struct Curl_mimepart *part = (struct Curl_mimepart *) instream;
- size_t sz = part->datasize - part->state.offset;
+ size_t sz = (size_t) part->datasize - part->state.offset;
(void) size; /* Always 1.*/
@@ -312,7 +312,7 @@ static int mime_mem_seek(void *instream, curl_off_t offset,
int whence)
if(offset < 0 || offset > part->datasize)
return CURL_SEEKFUNC_FAIL;
- part->state.offset = offset;
+ part->state.offset = (size_t) offset;
return CURL_SEEKFUNC_OK;
}
diff --git a/src/tool_setopt.c b/src/tool_setopt.c
index 6cb6bb3e3..4e25e9e12 100644
--- a/src/tool_setopt.c
+++ b/src/tool_setopt.c
@@ -210,14 +210,18 @@ static const NameValue setopt_nv_CURLNONZERODEFAULTS[] = {
/* Escape string to C string syntax. Return NULL if out of memory.
* Is this correct for those wacky EBCDIC guys? */
-static char *c_escape(const char *str, ssize_t len)
+static char *c_escape(const char *str, ssize_t plen)
{
const char *s;
unsigned char c;
char *escaped, *e;
+ size_t len = plen == -1? strlen(str): (size_t) plen;
+
+ /* Check for possible overflow. */
+ if(len > (~(size_t) 0) / 4)
+ return NULL;
+
/* Allocate space based on worst-case */
- if(len < 0)
- len = strlen(str);
escaped = malloc(4 * len + 1);
if(!escaped)
return NULL;
@@ -474,7 +478,7 @@ static CURLcode libcurl_generate_mime(curl_mime *mime, int
*mimeno)
;
size = (cp == data + part->datasize)? (curl_off_t) -1: part->datasize;
Curl_safefree(escaped);
- escaped = c_escape(data, part->datasize);
+ escaped = c_escape(data, (ssize_t) part->datasize);
if(data != part->data)
Curl_safefree(data);
if(!escaped)
--
To stop receiving notification emails like this one, please contact
address@hidden
- [GNUnet-SVN] [gnurl] 95/256: asyn-thread: Set errno to the proper value ENOMEM in OOM situation, (continued)
- [GNUnet-SVN] [gnurl] 95/256: asyn-thread: Set errno to the proper value ENOMEM in OOM situation, gnunet, 2017/10/06
- [GNUnet-SVN] [gnurl] 114/256: strcase: corrected comment header for Curl_strcasecompare(), gnunet, 2017/10/06
- [GNUnet-SVN] [gnurl] 151/256: openssl: use OpenSSL's default ciphers by default, gnunet, 2017/10/06
- [GNUnet-SVN] [gnurl] 156/256: runtests.pl: support attribute "nonewline" in part verify/upload., gnunet, 2017/10/06
- [GNUnet-SVN] [gnurl] 66/256: vtls: declare Curl_ssl structs for every SSL backend, gnunet, 2017/10/06
- [GNUnet-SVN] [gnurl] 36/256: scripts/contri*sh: use "git log --use-mailmap", gnunet, 2017/10/06
- [GNUnet-SVN] [gnurl] 141/256: test1135: fixed after bd8070085f9, gnunet, 2017/10/06
- [GNUnet-SVN] [gnurl] 70/256: vtls: convert the have_curlssl_* constants to runtime flags, gnunet, 2017/10/06
- [GNUnet-SVN] [gnurl] 104/256: curl_global_sslset.3: clarify, gnunet, 2017/10/06
- [GNUnet-SVN] [gnurl] 118/256: ossfuzz: Move to C++ for curl_fuzzer., gnunet, 2017/10/06
- [GNUnet-SVN] [gnurl] 129/256: mime: fix some implicit curl_off_t --> size_t conversion warnings.,
gnunet <=
- [GNUnet-SVN] [gnurl] 106/256: makefile.m32: add multissl support, gnunet, 2017/10/06
- [GNUnet-SVN] [gnurl] 85/256: vtls: refactor out essential information about the SSL backends, gnunet, 2017/10/06
- [GNUnet-SVN] [gnurl] 148/256: configure: add MultiSSL to FEATURES when enabled, gnunet, 2017/10/06
- [GNUnet-SVN] [gnurl] 211/256: RELEASE-NOTES: synced with 5fe85587c, gnunet, 2017/10/06
- [GNUnet-SVN] [gnurl] 99/256: asyn-thread: Fixed cleanup after OOM, gnunet, 2017/10/06
- [GNUnet-SVN] [gnurl] 109/256: polarssl: fix multissl breakage, gnunet, 2017/10/06
- [GNUnet-SVN] [gnurl] 84/256: vtls: allow selecting which SSL backend to use at runtime, gnunet, 2017/10/06
- [GNUnet-SVN] [gnurl] 125/256: test564: Add a warning comment about shell profile output., gnunet, 2017/10/06
- [GNUnet-SVN] [gnurl] 179/256: mbedtls: enable CA path processing, gnunet, 2017/10/06
- [GNUnet-SVN] [gnurl] 216/256: examples/post-callback: use long for CURLOPT_POSTFIELDSIZE, gnunet, 2017/10/06