Skip to content

Code Inconsistencies Detected by Static Analysis #2429

Open
@Anchels

Description

@Anchels

Return value of a function lua_touserdata is dereferenced without checking for NULL, but it is usually checked for this function:

cp = lua_touserdata(L, lua_upvalueindex(3));
dd("checking existing state: %d", cp->state);
if (cp->state == -1) {
cp->state = 0;
lua_pushnil(L);
lua_pushnil(L);
lua_pushnil(L);
return 3;
}

Similar issue with fucntion ngx_http_lua_get_req:

r = ngx_http_lua_get_req(L);
if (r != r->main) {
return luaL_error(L, "attempt to read the request body in a "
"subrequest");
}

After having been compared to a NULL value:

if (server_name != NULL && server_name->data != NULL) {
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
"lua ssl server name: \"%V\"", server_name);

pointer server_name->data is dereferenced without null check by calling function memcpy:

ngx_memcpy(u->ssl_name.data, server_name->data,
server_name->len);
u->ssl_name.len = server_name->len;

Found by Linux Verification Center with SVACE

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions