return NULL;
} else {
size_t ssb_len;
- char ssb_buf[128] = {0};
+ char ssb_buf[128];
- ssb_len = snprintf(ssb_buf, 127, "%ld=%ld=%ld", (long) ssb.sb.st_mtime,
+ ssb_len = snprintf(ssb_buf, sizeof(ssb_buf), "%ld=%ld=%ld", (long) ssb.sb.st_mtime,
(long) ssb.sb.st_ino,
(long) ssb.sb.st_size);
http_etag_update(ctx, ssb_buf, ssb_len);
/* {{{ char *http_date(time_t) */
PHP_HTTP_API char *_http_date(time_t t TSRMLS_DC)
{
+ char *date = NULL;
struct tm *gmtime, tmbuf;
if ((gmtime = php_gmtime_r(&t, &tmbuf))) {
- char *date = ecalloc(1, 31);
- snprintf(date, 30,
+ spprintf(&date, 0,
"%s, %02d %s %04d %02d:%02d:%02d GMT",
days[gmtime->tm_wday], gmtime->tm_mday,
months[gmtime->tm_mon], gmtime->tm_year + 1900,
gmtime->tm_hour, gmtime->tm_min, gmtime->tm_sec
);
- return date;
}
- return NULL;
+ return date;
}
/* }}} */
/* emit a content-length header */
char cl_header_str[128];
size_t cl_header_len;
- cl_header_len = snprintf(cl_header_str, lenof(cl_header_str), "Content-Length: %zu", content_length);
+ cl_header_len = snprintf(cl_header_str, sizeof(cl_header_str), "Content-Length: %zu", content_length);
http_send_header_string_ex(cl_header_str, cl_header_len, 1);
} else {
HTTP_G->send.deflate.encoding = 0;
FOREACH_KEYVAL(pos, zoption, header_key, header_val) {
if (header_key.type == HASH_KEY_IS_STRING) {
- char header[1024] = {0};
+ char header[1024];
ZVAL_ADDREF(*header_val);
convert_to_string_ex(header_val);
if (!strcasecmp(header_key.str, "range")) {
range_req = 1;
}
- snprintf(header, lenof(header), "%s: %s", header_key.str, Z_STRVAL_PP(header_val));
+ snprintf(header, sizeof(header), "%s: %s", header_key.str, Z_STRVAL_PP(header_val));
request->_cache.headers = curl_slist_append(request->_cache.headers, header);
zval_ptr_dtor(header_val);
}
}
/* etag */
if ((zoption = http_request_option(request, options, "etag", IS_STRING)) && Z_STRLEN_P(zoption)) {
- char match_header[1024] = {0}, *quoted_etag = NULL;
+ char match_header[1024], *quoted_etag = NULL;
if ((Z_STRVAL_P(zoption)[0] != '"') || (Z_STRVAL_P(zoption)[Z_STRLEN_P(zoption)-1] != '"')) {
spprintf("ed_etag, 0, "\"%s\"", Z_STRVAL_P(zoption));
}
- snprintf(match_header, lenof(match_header), "%s: %s", range_req?"If-Match":"If-None-Match", quoted_etag?quoted_etag:Z_STRVAL_P(zoption));
+ snprintf(match_header, sizeof(match_header), "%s: %s", range_req?"If-Match":"If-None-Match", quoted_etag?quoted_etag:Z_STRVAL_P(zoption));
request->_cache.headers = curl_slist_append(request->_cache.headers, match_header);
STR_FREE(quoted_etag);
}
char range_header_str[256];
size_t range_header_len;
- range_header_len = snprintf(range_header_str, lenof(range_header_str), "Content-Range: bytes %ld-%ld/%zu", Z_LVAL_PP(begin), Z_LVAL_PP(end), data_size);
+ range_header_len = snprintf(range_header_str, sizeof(range_header_str), "Content-Range: bytes %ld-%ld/%zu", Z_LVAL_PP(begin), Z_LVAL_PP(end), data_size);
http_send_status_header_ex(206, range_header_str, range_header_len, 1);
http_send_response_start(&s, Z_LVAL_PP(end)-Z_LVAL_PP(begin)+1);
http_send_response_data_fetch(&s, data_ptr, data_size, data_mode, Z_LVAL_PP(begin), Z_LVAL_PP(end) + 1);
char boundary_str[32], range_header_str[256];
size_t boundary_len, range_header_len;
- boundary_len = snprintf(boundary_str, lenof(boundary_str), "%lu%0.9f", (ulong) HTTP_G->request.time, (float) php_combined_lcg(TSRMLS_C));
- range_header_len = snprintf(range_header_str, lenof(range_header_str), "Content-Type: multipart/byteranges; boundary=%s", boundary_str);
+ boundary_len = snprintf(boundary_str, sizeof(boundary_str), "%lu%0.9f", (ulong) HTTP_G->request.time, (float) php_combined_lcg(TSRMLS_C));
+ range_header_len = snprintf(range_header_str, sizeof(range_header_str), "Content-Type: multipart/byteranges; boundary=%s", boundary_str);
http_send_status_header_ex(206, range_header_str, range_header_len, 1);
http_send_response_start(&s, 0);
HTTP_CRLF "Content-Range: bytes %ld-%ld/%zu" \
HTTP_CRLF HTTP_CRLF
- preface_len = snprintf(preface_str, lenof(preface_str), HTTP_RANGE_PREFACE, boundary_str, content_type, Z_LVAL_PP(begin), Z_LVAL_PP(end), data_size);
+ preface_len = snprintf(preface_str, sizeof(preface_str), HTTP_RANGE_PREFACE, boundary_str, content_type, Z_LVAL_PP(begin), Z_LVAL_PP(end), data_size);
http_send_response_data_plain(&s, preface_str, preface_len);
http_send_response_data_fetch(&s, data_ptr, data_size, data_mode, Z_LVAL_PP(begin), Z_LVAL_PP(end) + 1);
}
strlcat(*url_str, url->host, HTTP_URL_MAXLEN);
if (url->port) {
- char port_str[8] = {0};
+ char port_str[8];
- snprintf(port_str, lenof(port_str), "%d", (int) url->port);
+ snprintf(port_str, sizeof(port_str), "%d", (int) url->port);
strlcat(*url_str, ":", HTTP_URL_MAXLEN);
strlcat(*url_str, port_str, HTTP_URL_MAXLEN);
}