Skip to content

Commit 6f2279a

Browse files
committed
curl: Don't truncate length
Truncating to an int seems dangerous, esp. in combination with a MIN macro. I don't see a reason to truncate the length from size_t to int, and especially no reason to change the signedness.
1 parent 22aaa20 commit 6f2279a

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

ext/curl/interface.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -594,7 +594,7 @@ static size_t curl_write(char *data, size_t size, size_t nmemb, void *ctx)
594594
return fwrite(data, size, nmemb, t->fp);
595595
case PHP_CURL_RETURN:
596596
if (length > 0) {
597-
smart_str_appendl(&t->buf, data, (int) length);
597+
smart_str_appendl(&t->buf, data, length);
598598
}
599599
break;
600600
case PHP_CURL_USER: {
@@ -876,7 +876,7 @@ static size_t curl_read(char *data, size_t size, size_t nmemb, void *ctx)
876876
} else if (!Z_ISUNDEF(retval)) {
877877
_php_curl_verify_handlers(ch, /* reporterror */ true);
878878
if (Z_TYPE(retval) == IS_STRING) {
879-
length = MIN((int) (size * nmemb), Z_STRLEN(retval));
879+
length = MIN(size * nmemb, Z_STRLEN(retval));
880880
memcpy(data, Z_STRVAL(retval), length);
881881
} else if (Z_TYPE(retval) == IS_LONG) {
882882
length = Z_LVAL_P(&retval);
@@ -906,7 +906,7 @@ static size_t curl_write_header(char *data, size_t size, size_t nmemb, void *ctx
906906
/* Handle special case write when we're returning the entire transfer
907907
*/
908908
if (ch->handlers.write->method == PHP_CURL_RETURN && length > 0) {
909-
smart_str_appendl(&ch->handlers.write->buf, data, (int) length);
909+
smart_str_appendl(&ch->handlers.write->buf, data, length);
910910
} else {
911911
PHPWRITE(data, length);
912912
}

0 commit comments

Comments
 (0)