use li_[iu]tostrn() instead of li_[iu]tostr()
From: Glenn Strauss <gstrauss@gluelogic.com> git-svn-id: svn://svn.lighttpd.net/lighttpd/branches/lighttpd-1.4.x@3136 152afb58-edef-0310-8abb-c4023f1b3aa9
This commit is contained in:
parent
e5006d88eb
commit
47f3dbebe4
1
NEWS
1
NEWS
|
@ -59,6 +59,7 @@ NEWS
|
|||
* [mod_webdav] allow Depth: Infinity lock on file (fixes #2296)
|
||||
* [mod_status] use snprintf() instead of sprintf()
|
||||
* pass buf size to li_tohex()
|
||||
* use li_[iu]tostrn() instead of li_[iu]tostr()
|
||||
|
||||
- 1.4.39 - 2016-01-02
|
||||
* [core] fix memset_s call (fixes #2698)
|
||||
|
|
|
@ -355,10 +355,6 @@ void li_itostrn(char *buf, size_t buf_len, intmax_t val) {
|
|||
memcpy(buf, str, p_buf_end - str);
|
||||
}
|
||||
|
||||
void li_itostr(char *buf, intmax_t val) {
|
||||
li_itostrn(buf, LI_ITOSTRING_LENGTH, val);
|
||||
}
|
||||
|
||||
void li_utostrn(char *buf, size_t buf_len, uintmax_t val) {
|
||||
char p_buf[LI_ITOSTRING_LENGTH];
|
||||
char* const p_buf_end = p_buf + sizeof(p_buf);
|
||||
|
@ -372,10 +368,6 @@ void li_utostrn(char *buf, size_t buf_len, uintmax_t val) {
|
|||
memcpy(buf, str, p_buf_end - str);
|
||||
}
|
||||
|
||||
void li_utostr(char *buf, uintmax_t val) {
|
||||
li_utostrn(buf, LI_ITOSTRING_LENGTH, val);
|
||||
}
|
||||
|
||||
char int2hex(char c) {
|
||||
return hex_chars[(c & 0x0F)];
|
||||
}
|
||||
|
|
|
@ -96,9 +96,7 @@ void buffer_append_strftime(buffer *b, const char *format, const struct tm *tm);
|
|||
#define LI_ITOSTRING_LENGTH (2 + (8 * sizeof(intmax_t) * 31 + 99) / 100)
|
||||
|
||||
void li_itostrn(char *buf, size_t buf_len, intmax_t val);
|
||||
void li_itostr(char *buf, intmax_t val); /* buf must have at least LI_ITOSTRING_LENGTH bytes */
|
||||
void li_utostrn(char *buf, size_t buf_len, uintmax_t val);
|
||||
void li_utostr(char *buf, uintmax_t val); /* buf must have at least LI_ITOSTRING_LENGTH bytes */
|
||||
|
||||
/* buf must be (at least) 2*s_len + 1 big. uses lower-case hex letters. */
|
||||
void li_tohex(char *buf, size_t buf_len, const char *s, size_t s_len);
|
||||
|
|
|
@ -1104,10 +1104,10 @@ int http_auth_digest_generate_nonce(server *srv, mod_auth_plugin_data *p, buffer
|
|||
li_MD5_Update(&Md5Ctx, CONST_STR_LEN("+"));
|
||||
|
||||
/* we assume sizeof(time_t) == 4 here, but if not it ain't a problem at all */
|
||||
li_itostr(hh, srv->cur_ts);
|
||||
li_itostrn(hh, sizeof(hh), srv->cur_ts);
|
||||
li_MD5_Update(&Md5Ctx, (unsigned char *)hh, strlen(hh));
|
||||
li_MD5_Update(&Md5Ctx, (unsigned char *)srv->entropy, sizeof(srv->entropy));
|
||||
li_itostr(hh, rand());
|
||||
li_itostrn(hh, sizeof(hh), rand());
|
||||
li_MD5_Update(&Md5Ctx, (unsigned char *)hh, strlen(hh));
|
||||
|
||||
li_MD5_Final(h, &Md5Ctx);
|
||||
|
|
|
@ -911,7 +911,7 @@ static int cgi_create_env(server *srv, connection *con, plugin_data *p, buffer *
|
|||
force_assert(s);
|
||||
cgi_env_add(&env, CONST_STR_LEN("SERVER_PROTOCOL"), s, strlen(s));
|
||||
|
||||
li_utostr(buf,
|
||||
li_utostrn(buf, sizeof(buf),
|
||||
#ifdef HAVE_IPV6
|
||||
ntohs(srv_sock->addr.plain.sa_family == AF_INET6 ? srv_sock->addr.ipv6.sin6_port : srv_sock->addr.ipv4.sin_port)
|
||||
#else
|
||||
|
@ -988,7 +988,7 @@ static int cgi_create_env(server *srv, connection *con, plugin_data *p, buffer *
|
|||
force_assert(s);
|
||||
cgi_env_add(&env, CONST_STR_LEN("REMOTE_ADDR"), s, strlen(s));
|
||||
|
||||
li_utostr(buf,
|
||||
li_utostrn(buf, sizeof(buf),
|
||||
#ifdef HAVE_IPV6
|
||||
ntohs(con->dst_addr.plain.sa_family == AF_INET6 ? con->dst_addr.ipv6.sin6_port : con->dst_addr.ipv4.sin_port)
|
||||
#else
|
||||
|
@ -1001,7 +1001,7 @@ static int cgi_create_env(server *srv, connection *con, plugin_data *p, buffer *
|
|||
cgi_env_add(&env, CONST_STR_LEN("HTTPS"), CONST_STR_LEN("on"));
|
||||
}
|
||||
|
||||
li_itostr(buf, con->request.content_length);
|
||||
li_itostrn(buf, sizeof(buf), con->request.content_length);
|
||||
cgi_env_add(&env, CONST_STR_LEN("CONTENT_LENGTH"), buf, strlen(buf));
|
||||
cgi_env_add(&env, CONST_STR_LEN("SCRIPT_FILENAME"), CONST_BUF_LEN(con->physical.path));
|
||||
cgi_env_add(&env, CONST_STR_LEN("SCRIPT_NAME"), CONST_BUF_LEN(con->uri.path));
|
||||
|
|
|
@ -465,7 +465,7 @@ static int http_list_directory_sizefmt(char *buf, off_t size) {
|
|||
u++;
|
||||
}
|
||||
|
||||
li_itostr(out, size);
|
||||
li_itostrn(out, 4, size);
|
||||
out += strlen(out);
|
||||
out[0] = '.';
|
||||
out[1] = remain + '0';
|
||||
|
|
|
@ -1871,7 +1871,7 @@ static int fcgi_create_env(server *srv, handler_ctx *hctx, size_t request_id) {
|
|||
|
||||
FCGI_ENV_ADD_CHECK(fcgi_env_add(p->fcgi_env, CONST_STR_LEN("GATEWAY_INTERFACE"), CONST_STR_LEN("CGI/1.1")),con)
|
||||
|
||||
li_utostr(buf,
|
||||
li_utostrn(buf, sizeof(buf),
|
||||
#ifdef HAVE_IPV6
|
||||
ntohs(srv_sock->addr.plain.sa_family ? srv_sock->addr.ipv6.sin6_port : srv_sock->addr.ipv4.sin_port)
|
||||
#else
|
||||
|
@ -1891,7 +1891,7 @@ static int fcgi_create_env(server *srv, handler_ctx *hctx, size_t request_id) {
|
|||
}
|
||||
FCGI_ENV_ADD_CHECK(fcgi_env_add(p->fcgi_env, CONST_STR_LEN("SERVER_ADDR"), s, strlen(s)),con)
|
||||
|
||||
li_utostr(buf,
|
||||
li_utostrn(buf, sizeof(buf),
|
||||
#ifdef HAVE_IPV6
|
||||
ntohs(con->dst_addr.plain.sa_family ? con->dst_addr.ipv6.sin6_port : con->dst_addr.ipv4.sin_port)
|
||||
#else
|
||||
|
@ -1907,7 +1907,7 @@ static int fcgi_create_env(server *srv, handler_ctx *hctx, size_t request_id) {
|
|||
if (con->request.content_length > 0 && host->mode != FCGI_AUTHORIZER) {
|
||||
/* CGI-SPEC 6.1.2 and FastCGI spec 6.3 */
|
||||
|
||||
li_itostr(buf, con->request.content_length);
|
||||
li_itostrn(buf, sizeof(buf), con->request.content_length);
|
||||
FCGI_ENV_ADD_CHECK(fcgi_env_add(p->fcgi_env, CONST_STR_LEN("CONTENT_LENGTH"), buf, strlen(buf)),con)
|
||||
}
|
||||
|
||||
|
|
|
@ -1480,7 +1480,7 @@ static int scgi_create_env(server *srv, handler_ctx *hctx) {
|
|||
|
||||
/* CGI-SPEC 6.1.2, FastCGI spec 6.3 and SCGI spec */
|
||||
|
||||
li_itostr(buf, con->request.content_length);
|
||||
li_itostrn(buf, sizeof(buf), con->request.content_length);
|
||||
scgi_env_add(p->scgi_env, CONST_STR_LEN("CONTENT_LENGTH"), buf, strlen(buf));
|
||||
scgi_env_add(p->scgi_env, CONST_STR_LEN("SCGI"), CONST_STR_LEN("1"));
|
||||
|
||||
|
@ -1519,7 +1519,7 @@ static int scgi_create_env(server *srv, handler_ctx *hctx) {
|
|||
|
||||
scgi_env_add(p->scgi_env, CONST_STR_LEN("GATEWAY_INTERFACE"), CONST_STR_LEN("CGI/1.1"));
|
||||
|
||||
li_utostr(buf,
|
||||
li_utostrn(buf, sizeof(buf),
|
||||
#ifdef HAVE_IPV6
|
||||
ntohs(srv_sock->addr.plain.sa_family ? srv_sock->addr.ipv6.sin6_port : srv_sock->addr.ipv4.sin_port)
|
||||
#else
|
||||
|
@ -1539,7 +1539,7 @@ static int scgi_create_env(server *srv, handler_ctx *hctx) {
|
|||
}
|
||||
scgi_env_add(p->scgi_env, CONST_STR_LEN("SERVER_ADDR"), s, strlen(s));
|
||||
|
||||
li_utostr(buf,
|
||||
li_utostrn(buf, sizeof(buf),
|
||||
#ifdef HAVE_IPV6
|
||||
ntohs(con->dst_addr.plain.sa_family ? con->dst_addr.ipv6.sin6_port : con->dst_addr.ipv4.sin_port)
|
||||
#else
|
||||
|
|
|
@ -232,7 +232,7 @@ static int build_ssi_cgi_vars(server *srv, connection *con, plugin_data *p) {
|
|||
);
|
||||
ssi_env_add(p->ssi_cgi_env, CONST_STRING("GATEWAY_INTERFACE"), "CGI/1.1");
|
||||
|
||||
li_utostr(buf,
|
||||
li_utostrn(buf, sizeof(buf),
|
||||
#ifdef HAVE_IPV6
|
||||
ntohs(srv_sock->addr.plain.sa_family ? srv_sock->addr.ipv6.sin6_port : srv_sock->addr.ipv4.sin_port)
|
||||
#else
|
||||
|
@ -248,7 +248,7 @@ static int build_ssi_cgi_vars(server *srv, connection *con, plugin_data *p) {
|
|||
if (con->request.content_length > 0) {
|
||||
/* CGI-SPEC 6.1.2 and FastCGI spec 6.3 */
|
||||
|
||||
li_itostr(buf, con->request.content_length);
|
||||
li_itostrn(buf, sizeof(buf), con->request.content_length);
|
||||
ssi_env_add(p->ssi_cgi_env, CONST_STRING("CONTENT_LENGTH"), buf);
|
||||
}
|
||||
|
||||
|
|
|
@ -228,10 +228,10 @@ URIHANDLER_FUNC(mod_usertrack_uri_handler) {
|
|||
li_MD5_Update(&Md5Ctx, CONST_STR_LEN("+"));
|
||||
|
||||
/* we assume sizeof(time_t) == 4 here, but if not it ain't a problem at all */
|
||||
li_itostr(hh, srv->cur_ts);
|
||||
li_itostrn(hh, sizeof(hh), srv->cur_ts);
|
||||
li_MD5_Update(&Md5Ctx, (unsigned char *)hh, strlen(hh));
|
||||
li_MD5_Update(&Md5Ctx, (unsigned char *)srv->entropy, sizeof(srv->entropy));
|
||||
li_itostr(hh, rand());
|
||||
li_itostrn(hh, sizeof(hh), rand());
|
||||
li_MD5_Update(&Md5Ctx, (unsigned char *)hh, strlen(hh));
|
||||
|
||||
li_MD5_Final(h, &Md5Ctx);
|
||||
|
|
Loading…
Reference in New Issue