1
0
mirror of https://github.com/apache/httpd.git synced 2025-08-05 16:55:50 +03:00

mod_lua: Fix signedness/other small bugs as per cjaillet/fuankg's emails - thanks guys :)

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1421780 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Daniel Gruno
2012-12-14 10:15:37 +00:00
parent 9875cc5fab
commit df178d1e41
3 changed files with 41 additions and 54 deletions

View File

@@ -233,9 +233,12 @@ static int lua_ap_unescape (lua_State *L) {
plain = apr_pstrdup(r->pool, escaped);
strncpy(plain, escaped, x);
y = ap_unescape_urlencoded(plain);
if (!y) {
lua_pushstring(L, plain);
return 1;
}
return 0;
}
/* lua_ap_escape; r:escape(string) - URL-escapes a string */
static int lua_ap_escape (lua_State *L) {
@@ -246,7 +249,6 @@ static int lua_ap_escape (lua_State *L) {
r = ap_lua_check_request_rec(L, 1);
luaL_checktype(L, 2, LUA_TSTRING);
plain = lua_tolstring(L, 2, &x);
escaped = apr_pcalloc(r->pool, x*3);
escaped = ap_escape_urlencoded(r->pool, plain);
lua_pushstring(L, escaped);
return 1;
@@ -256,9 +258,8 @@ static int lua_ap_escape (lua_State *L) {
static int lua_apr_md5(lua_State *L)
{
/*~~~~~~~~~~~~~~~~*/
int n;
union {
char chr[16];
unsigned char chr[16];
uint32_t num[4];
} digest;
apr_md5_ctx_t md5;
@@ -294,15 +295,14 @@ static int lua_apr_md5(lua_State *L)
static int lua_apr_sha1(lua_State *L)
{
/*~~~~~~~~~~~~~~~~*/
int n;
union {
char chr[16];
unsigned char chr[16];
uint32_t num[4];
} digest;
apr_sha1_ctx_t sha1;
const char* buffer;
char* result;
char Rsha1[16];
unsigned char Rsha1[20];
uint32_t *sha1X;
size_t x,y;
request_rec *r;
@@ -355,7 +355,6 @@ static int lua_ap_port(lua_State *L)
static int lua_ap_mpm_query(lua_State *L)
{
/*~~~~~~~~~~~~~~~~~~*/
request_rec *r;
int x,y;
/*~~~~~~~~~~~~~~~~~~*/
x = lua_tonumber(L, 1);
@@ -426,8 +425,6 @@ static int lua_ap_regex(lua_State *L)
return 0;
}
if (!err) {
int i;
x = ap_regexec(&regex, source, 10, matches, 0);
if (x < 0) {
@@ -448,8 +445,6 @@ static int lua_ap_regex(lua_State *L)
}
return 1;
}
return 0;
}
@@ -458,13 +453,11 @@ static int lua_ap_regex(lua_State *L)
static int lua_ap_scoreboard_process(lua_State *L)
{
/*~~~~~~~~~~~~~~~~~~*/
request_rec *r;
int i;
process_score* ps_record;
/*~~~~~~~~~~~~~~~~~~*/
luaL_checktype(L, 1, LUA_TUSERDATA);
luaL_checktype(L, 2, LUA_TNUMBER);
r = ap_lua_check_request_rec(L, 1);
i = lua_tonumber(L, 2);
ps_record = ap_get_scoreboard_process(i);
if (ps_record) {
@@ -511,14 +504,12 @@ static int lua_ap_scoreboard_process(lua_State *L)
static int lua_ap_scoreboard_worker(lua_State *L)
{
/*~~~~~~~~~~~~~~~~~~*/
request_rec *r;
int i,j;
worker_score* ws_record;
/*~~~~~~~~~~~~~~~~~~*/
luaL_checktype(L, 1, LUA_TUSERDATA);
luaL_checktype(L, 2, LUA_TNUMBER);
luaL_checktype(L, 3, LUA_TNUMBER);
r = ap_lua_check_request_rec(L, 1);
i = lua_tonumber(L, 2);
j = lua_tonumber(L, 3);
ws_record = ap_get_scoreboard_worker_from_indexes(i, j);
@@ -618,7 +609,7 @@ static int lua_ap_requestbody(lua_State *L)
request_rec* r;
/*~~~~~~~~~~~~~~~~~~*/
r = r = ap_lua_check_request_rec(L, 1);
r = ap_lua_check_request_rec(L, 1);
filename = luaL_optstring(L, 2, 0);
if (r) {
@@ -703,7 +694,6 @@ static int lua_ap_add_input_filter(lua_State *L)
static int lua_ap_module_info(lua_State *L)
{
/*~~~~~~~~~~~~~~~~~~*/
request_rec *r;
const char* moduleName;
module* mod;
/*~~~~~~~~~~~~~~~~~~*/

View File

@@ -227,7 +227,7 @@ static int req_parsebody(lua_State *L)
int i, z;
size_t vlen = 0;
size_t len = 0;
if (lua_read_body(r, &data, &size) != OK) {
if (lua_read_body(r, &data, (apr_off_t*) &size) != OK) {
return 2;
}
len = strlen(multipart);
@@ -574,7 +574,6 @@ static int lua_ap_sendfile(lua_State *L)
lua_pushboolean(L, 0);
}
else {
if (r) {
apr_size_t sent;
apr_status_t rc;
apr_file_t *file;
@@ -586,11 +585,9 @@ static int lua_ap_sendfile(lua_State *L)
apr_file_close(file);
lua_pushinteger(L, sent);
}
else
else {
lua_pushboolean(L, 0);
}
else
lua_pushboolean(L, 0);
}
return (1);

View File

@@ -83,7 +83,7 @@ typedef enum {
AP_LUA_INHERIT_UNSET = -1,
AP_LUA_INHERIT_NONE = 0,
AP_LUA_INHERIT_PARENT_FIRST = 1,
AP_LUA_INHERIT_PARENT_LAST = 2,
AP_LUA_INHERIT_PARENT_LAST = 2
} ap_lua_inherit_t;
/**