Skip to content

Commit 4dc55c1

Browse files
author
Sterling Hughes
committed
Fix possible corruption problem with curl_errno() and curl_error()
1 parent d097b0e commit 4dc55c1

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

ext/curl/curl.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -507,7 +507,8 @@ static void alloc_curl_handle(php_curl **ch)
507507
(*ch)->handlers->write = ecalloc(1, sizeof(php_curl_write));
508508
(*ch)->handlers->write_header = ecalloc(1, sizeof(php_curl_write));
509509
(*ch)->handlers->read = ecalloc(1, sizeof(php_curl_read));
510-
510+
memset(&(*ch)->err, 0, sizeof((*ch)->err));
511+
511512
zend_llist_init(&(*ch)->to_free.str, sizeof(char *),
512513
(void(*)(void *)) curl_free_string, 0);
513514
zend_llist_init(&(*ch)->to_free.slist, sizeof(struct curl_slist),
@@ -943,6 +944,7 @@ PHP_FUNCTION(curl_error)
943944
}
944945
ZEND_FETCH_RESOURCE(ch, php_curl *, zid, -1, le_curl_name, le_curl);
945946

947+
ch->err.str[CURL_ERROR_SIZE] = 0;
946948
RETURN_STRING(ch->err.str, 1);
947949
}
948950
/* }}} */

0 commit comments

Comments
 (0)