{
"lauxlib.c": [
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lauxlib.c",
"line": 47,
"message": "Recursive function can cause excessive stack allocation",
"rule_id": "MEM05-C",
"severity": "Medium",
"suggestion": "Consider iterative approach or limit recursion depth"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lauxlib.c",
"line": 127,
"message": "Function 'luaL_traceback' does not validate pointer parameter 'L' before use",
"rule_id": "API00-C",
"severity": "Medium",
"suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lauxlib.c",
"line": 127,
"message": "Function 'luaL_traceback' does not validate pointer parameter 'L1' before use",
"rule_id": "API00-C",
"severity": "Medium",
"suggestion": "Add validation check for 'L1' at the start of the function, e.g., 'if (!L1) { return error_code; }'"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lauxlib.c",
"line": 127,
"message": "Function 'luaL_traceback' should be declared static if it doesn't need external linkage",
"rule_id": "DCL15-C",
"severity": "Low",
"suggestion": "Add 'static' storage-class specifier: static LUALIB_API luaL_traceback"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lauxlib.c",
"line": 171,
"message": "Function 'luaL_argerror' does not validate pointer parameter 'extramsg' before use",
"rule_id": "API00-C",
"severity": "Medium",
"suggestion": "Add validation check for 'extramsg' at the start of the function, e.g., 'if (!extramsg) { return error_code; }'"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lauxlib.c",
"line": 171,
"message": "Function 'luaL_argerror' should be declared static if it doesn't need external linkage",
"rule_id": "DCL15-C",
"severity": "Low",
"suggestion": "Add 'static' storage-class specifier: static LUALIB_API luaL_argerror"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lauxlib.c",
"line": 171,
"message": "Function 'luaL_argerror' is only used within this file. It should be declared static to minimize scope.",
"rule_id": "DCL19-C",
"severity": "Low",
"suggestion": "Add 'static' storage class to function 'luaL_argerror'"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lauxlib.c",
"line": 197,
"message": "Function 'luaL_typeerror' does not validate pointer parameter 'L' before use",
"rule_id": "API00-C",
"severity": "Medium",
"suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lauxlib.c",
"line": 197,
"message": "Function 'luaL_typeerror' does not validate pointer parameter 'tname' before use",
"rule_id": "API00-C",
"severity": "Medium",
"suggestion": "Add validation check for 'tname' at the start of the function, e.g., 'if (!tname) { return error_code; }'"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lauxlib.c",
"line": 197,
"message": "Function 'luaL_typeerror' should be declared static if it doesn't need external linkage",
"rule_id": "DCL15-C",
"severity": "Low",
"suggestion": "Add 'static' storage-class specifier: static LUALIB_API luaL_typeerror"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lauxlib.c",
"line": 197,
"message": "Function 'luaL_typeerror' is only used within this file. It should be declared static to minimize scope.",
"rule_id": "DCL19-C",
"severity": "Low",
"suggestion": "Add 'static' storage class to function 'luaL_typeerror'"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lauxlib.c",
"line": 220,
"message": "Function 'luaL_where' does not validate pointer parameter 'L' before use",
"rule_id": "API00-C",
"severity": "Medium",
"suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lauxlib.c",
"line": 220,
"message": "Function 'luaL_where' should be declared static if it doesn't need external linkage",
"rule_id": "DCL15-C",
"severity": "Low",
"suggestion": "Add 'static' storage-class specifier: static LUALIB_API luaL_where"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lauxlib.c",
"line": 220,
"message": "Function 'luaL_where' is only used within this file. It should be declared static to minimize scope.",
"rule_id": "DCL19-C",
"severity": "Low",
"suggestion": "Add 'static' storage class to function 'luaL_where'"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lauxlib.c",
"line": 238,
"message": "Function 'luaL_error' does not validate pointer parameter 'L' before use",
"rule_id": "API00-C",
"severity": "Medium",
"suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lauxlib.c",
"line": 238,
"message": "Function 'luaL_error' does not validate pointer parameter 'fmt' before use",
"rule_id": "API00-C",
"severity": "Medium",
"suggestion": "Add validation check for 'fmt' at the start of the function, e.g., 'if (!fmt) { return error_code; }'"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lauxlib.c",
"line": 238,
"message": "Function 'luaL_error' should be declared static if it doesn't need external linkage",
"rule_id": "DCL15-C",
"severity": "Low",
"suggestion": "Add 'static' storage-class specifier: static LUALIB_API luaL_error"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lauxlib.c",
"line": 238,
"message": "Function 'luaL_error' is only used within this file. It should be declared static to minimize scope.",
"rule_id": "DCL19-C",
"severity": "Low",
"suggestion": "Add 'static' storage class to function 'luaL_error'"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lauxlib.c",
"line": 249,
"message": "Function 'luaL_fileresult' should be declared static if it doesn't need external linkage",
"rule_id": "DCL15-C",
"severity": "Low",
"suggestion": "Add 'static' storage-class specifier: static LUALIB_API luaL_fileresult"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lauxlib.c",
"line": 249,
"message": "Function 'luaL_fileresult' is only used within this file. It should be declared static to minimize scope.",
"rule_id": "DCL19-C",
"severity": "Low",
"suggestion": "Add 'static' storage class to function 'luaL_fileresult'"
},
{
"column": 23,
"file": "/home/brandon/toolchain/lua/lauxlib.c",
"line": 258,
"message": "Call to non-thread-safe function 'strerror'. Use strerror_r() (POSIX) or strerror_s() (C11 Annex K) for thread-safe error reporting",
"rule_id": "CON33-C",
"severity": "Medium",
"suggestion": "Use strerror_r() (POSIX) or strerror_s() (C11 Annex K) for thread-safe error reporting"
},
{
"column": 23,
"file": "/home/brandon/toolchain/lua/lauxlib.c",
"line": 258,
"message": "'strerror()' uses internal static storage that is shared between threads",
"rule_id": "CON34-C",
"severity": "Medium",
"suggestion": "Use 'strerror_r' instead for thread safety"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lauxlib.c",
"line": 278,
"message": "Function-like macro 'l_inspectstat' evaluates parameter(s) multiple times; prefer inline or static functions for type safety",
"rule_id": "PRE00-C",
"severity": "Low",
"suggestion": null
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lauxlib.c",
"line": 278,
"message": "Macro parameter 'stat' is not parenthesized in replacement text. This can cause operator precedence issues.",
"rule_id": "PRE01-C",
"severity": "Medium",
"suggestion": "Wrap parameter 'stat' in parentheses: (stat) instead of stat"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lauxlib.c",
"line": 278,
"message": "Macro parameter 'what' is not parenthesized in replacement text. This can cause operator precedence issues.",
"rule_id": "PRE01-C",
"severity": "Medium",
"suggestion": "Wrap parameter 'what' in parentheses: (what) instead of what"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lauxlib.c",
"line": 278,
"message": "Multistatement macro 'l_inspectstat' is not wrapped in a do-while loop. This can cause issues when used in if statements without braces",
"rule_id": "PRE10-C",
"severity": "Medium",
"suggestion": "Wrap the macro body in: do { /* statements */ } while (0)"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lauxlib.c",
"line": 278,
"message": "Macro evaluates parameter 'stat' multiple times; use inline function instead",
"rule_id": "PRE12-C",
"severity": "Medium",
"suggestion": "Replace macro with inline function to avoid multiple evaluation"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lauxlib.c",
"line": 291,
"message": "Function 'luaL_execresult' should be declared static if it doesn't need external linkage",
"rule_id": "DCL15-C",
"severity": "Low",
"suggestion": "Add 'static' storage-class specifier: static LUALIB_API luaL_execresult"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lauxlib.c",
"line": 317,
"message": "Function 'luaL_newmetatable' should be declared static if it doesn't need external linkage",
"rule_id": "DCL15-C",
"severity": "Low",
"suggestion": "Add 'static' storage-class specifier: static LUALIB_API luaL_newmetatable"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lauxlib.c",
"line": 317,
"message": "Function 'luaL_newmetatable' is only used within this file. It should be declared static to minimize scope.",
"rule_id": "DCL19-C",
"severity": "Low",
"suggestion": "Add 'static' storage class to function 'luaL_newmetatable'"
},
{
"column": 3,
"file": "/home/brandon/toolchain/lua/lauxlib.c",
"line": 323,
"message": "Passing string literal to function 'lua_setfield' which may modify it",
"rule_id": "STR30-C",
"severity": "High",
"suggestion": "Use a modifiable array instead of a string literal"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lauxlib.c",
"line": 330,
"message": "Function 'luaL_setmetatable' does not validate pointer parameter 'L' before use",
"rule_id": "API00-C",
"severity": "Medium",
"suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lauxlib.c",
"line": 330,
"message": "Function 'luaL_setmetatable' does not validate pointer parameter 'tname' before use",
"rule_id": "API00-C",
"severity": "Medium",
"suggestion": "Add validation check for 'tname' at the start of the function, e.g., 'if (!tname) { return error_code; }'"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lauxlib.c",
"line": 330,
"message": "Function 'luaL_setmetatable' should be declared static if it doesn't need external linkage",
"rule_id": "DCL15-C",
"severity": "Low",
"suggestion": "Add 'static' storage-class specifier: static LUALIB_API luaL_setmetatable"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lauxlib.c",
"line": 336,
"message": "Function 'luaL_testudata' does not validate pointer parameter 'L' before use",
"rule_id": "API00-C",
"severity": "Medium",
"suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"
},
{
"column": 7,
"file": "/home/brandon/toolchain/lua/lauxlib.c",
"line": 344,
"message": "Function returns pointer to local variable 'p' with automatic storage duration",
"rule_id": "DCL30-C",
"severity": "High",
"suggestion": "Use static storage, allocated memory, or pass output buffer as parameter"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lauxlib.c",
"line": 351,
"message": "Function 'luaL_checkudata' does not validate pointer parameter 'L' before use",
"rule_id": "API00-C",
"severity": "Medium",
"suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lauxlib.c",
"line": 351,
"message": "Function 'luaL_checkudata' does not validate pointer parameter 'tname' before use",
"rule_id": "API00-C",
"severity": "Medium",
"suggestion": "Add validation check for 'tname' at the start of the function, e.g., 'if (!tname) { return error_code; }'"
},
{
"column": 3,
"file": "/home/brandon/toolchain/lua/lauxlib.c",
"line": 354,
"message": "Function returns pointer to local variable 'p' with automatic storage duration",
"rule_id": "DCL30-C",
"severity": "High",
"suggestion": "Use static storage, allocated memory, or pass output buffer as parameter"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lauxlib.c",
"line": 366,
"message": "Function 'luaL_checkoption' does not validate pointer parameter 'L' before use",
"rule_id": "API00-C",
"severity": "Medium",
"suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lauxlib.c",
"line": 366,
"message": "Function 'luaL_checkoption' does not validate pointer parameter 'def' before use",
"rule_id": "API00-C",
"severity": "Medium",
"suggestion": "Add validation check for 'def' at the start of the function, e.g., 'if (!def) { return error_code; }'"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lauxlib.c",
"line": 366,
"message": "Function 'luaL_checkoption' does not validate pointer parameter 'lst' before use",
"rule_id": "API00-C",
"severity": "Medium",
"suggestion": "Add validation check for 'lst' at the start of the function, e.g., 'if (!lst) { return error_code; }'"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lauxlib.c",
"line": 366,
"message": "Function 'luaL_checkoption' should be declared static if it doesn't need external linkage",
"rule_id": "DCL15-C",
"severity": "Low",
"suggestion": "Add 'static' storage-class specifier: static LUALIB_API luaL_checkoption"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lauxlib.c",
"line": 386,
"message": "Function 'luaL_checkstack' should be declared static if it doesn't need external linkage",
"rule_id": "DCL15-C",
"severity": "Low",
"suggestion": "Add 'static' storage-class specifier: static LUALIB_API luaL_checkstack"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lauxlib.c",
"line": 386,
"message": "Function 'luaL_checkstack' is only used within this file. It should be declared static to minimize scope.",
"rule_id": "DCL19-C",
"severity": "Low",
"suggestion": "Add 'static' storage class to function 'luaL_checkstack'"
},
{
"column": 18,
"file": "/home/brandon/toolchain/lua/lauxlib.c",
"line": 387,
"message": "Implicit boolean test on 'lua_checkstack(L, space)'. May be unclear what constitutes success or failure.",
"rule_id": "EXP20-C",
"severity": "Medium",
"suggestion": "Use explicit test: lua_checkstack(L, space) == 0 or lua_checkstack(L, space) != 0 depending on success convention"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lauxlib.c",
"line": 396,
"message": "Function 'luaL_checktype' should be declared static if it doesn't need external linkage",
"rule_id": "DCL15-C",
"severity": "Low",
"suggestion": "Add 'static' storage-class specifier: static LUALIB_API luaL_checktype"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lauxlib.c",
"line": 402,
"message": "Function 'luaL_checkany' should be declared static if it doesn't need external linkage",
"rule_id": "DCL15-C",
"severity": "Low",
"suggestion": "Add 'static' storage-class specifier: static LUALIB_API luaL_checkany"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lauxlib.c",
"line": 408,
"message": "Function 'luaL_checklstring' does not validate pointer parameter 'L' before use",
"rule_id": "API00-C",
"severity": "Medium",
"suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"
},
{
"column": 3,
"file": "/home/brandon/toolchain/lua/lauxlib.c",
"line": 411,
"message": "Function returns pointer to local variable 's' with automatic storage duration",
"rule_id": "DCL30-C",
"severity": "High",
"suggestion": "Use static storage, allocated memory, or pass output buffer as parameter"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lauxlib.c",
"line": 415,
"message": "Function 'luaL_optlstring' does not validate pointer parameter 'len' before use",
"rule_id": "API00-C",
"severity": "Medium",
"suggestion": "Add validation check for 'len' at the start of the function, e.g., 'if (!len) { return error_code; }'"
},
{
"column": 52,
"file": "/home/brandon/toolchain/lua/lauxlib.c",
"line": 416,
"message": "Pointer parameter should use conformant array syntax",
"rule_id": "API05-C",
"severity": "High",
"suggestion": "Use conformant array parameter syntax (e.g., 'char p[n]') with the size parameter declared before the array"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lauxlib.c",
"line": 426,
"message": "Function 'luaL_checknumber' does not validate pointer parameter 'L' before use",
"rule_id": "API00-C",
"severity": "Medium",
"suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lauxlib.c",
"line": 426,
"message": "Function 'luaL_checknumber' should be declared static if it doesn't need external linkage",
"rule_id": "DCL15-C",
"severity": "Low",
"suggestion": "Add 'static' storage-class specifier: static LUALIB_API luaL_checknumber"
},
{
"column": 19,
"file": "/home/brandon/toolchain/lua/lauxlib.c",
"line": 429,
"message": "Variable 'isnum' is used uninitialized",
"rule_id": "EXP33-C",
"severity": "High",
"suggestion": "Initialize 'isnum' before use, e.g., at its declaration"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lauxlib.c",
"line": 435,
"message": "Function 'luaL_optnumber' does not validate pointer parameter 'L' before use",
"rule_id": "API00-C",
"severity": "Medium",
"suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lauxlib.c",
"line": 435,
"message": "Function 'luaL_optnumber' should be declared static if it doesn't need external linkage",
"rule_id": "DCL15-C",
"severity": "Low",
"suggestion": "Add 'static' storage-class specifier: static LUALIB_API luaL_optnumber"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lauxlib.c",
"line": 448,
"message": "Function 'luaL_checkinteger' does not validate pointer parameter 'L' before use",
"rule_id": "API00-C",
"severity": "Medium",
"suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lauxlib.c",
"line": 448,
"message": "Function 'luaL_checkinteger' should be declared static if it doesn't need external linkage",
"rule_id": "DCL15-C",
"severity": "Low",
"suggestion": "Add 'static' storage-class specifier: static LUALIB_API luaL_checkinteger"
},
{
"column": 19,
"file": "/home/brandon/toolchain/lua/lauxlib.c",
"line": 451,
"message": "Variable 'isnum' is used uninitialized",
"rule_id": "EXP33-C",
"severity": "High",
"suggestion": "Initialize 'isnum' before use, e.g., at its declaration"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lauxlib.c",
"line": 458,
"message": "Function 'luaL_optinteger' does not validate pointer parameter 'L' before use",
"rule_id": "API00-C",
"severity": "Medium",
"suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lauxlib.c",
"line": 458,
"message": "Function 'luaL_optinteger' should be declared static if it doesn't need external linkage",
"rule_id": "DCL15-C",
"severity": "Low",
"suggestion": "Add 'static' storage-class specifier: static LUALIB_API luaL_optinteger"
},
{
"column": 7,
"file": "/home/brandon/toolchain/lua/lauxlib.c",
"line": 486,
"message": "Potential null pointer dereference in member access of variable 'box'",
"rule_id": "EXP34-C",
"severity": "High",
"suggestion": "Check if 'box' is not NULL before member access"
},
{
"column": 18,
"file": "/home/brandon/toolchain/lua/lauxlib.c",
"line": 491,
"message": "Function 'allocf' is called without prior declaration",
"rule_id": "DCL31-C",
"severity": "Low",
"suggestion": "Declare the function before calling it or include the appropriate header"
},
{
"column": 25,
"file": "/home/brandon/toolchain/lua/lauxlib.c",
"line": 491,
"message": "Variable 'ud' is used uninitialized",
"rule_id": "EXP33-C",
"severity": "High",
"suggestion": "Initialize 'ud' before use, e.g., at its declaration"
},
{
"column": 23,
"file": "/home/brandon/toolchain/lua/lauxlib.c",
"line": 509,
"message": "Array declaration 'boxmt[]' has implicit bounds; specify explicit size",
"rule_id": "ARR02-C",
"severity": "Medium",
"suggestion": "Explicitly specify array bounds even when using an initializer"
},
{
"column": 3,
"file": "/home/brandon/toolchain/lua/lauxlib.c",
"line": 518,
"message": "Potential null pointer dereference in member access of variable 'box'",
"rule_id": "EXP34-C",
"severity": "High",
"suggestion": "Check if 'box' is not NULL before member access"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lauxlib.c",
"line": 530,
"message": "Function-like macro 'buffonstack' evaluates parameter(s) multiple times; prefer inline or static functions for type safety",
"rule_id": "PRE00-C",
"severity": "Low",
"suggestion": null
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lauxlib.c",
"line": 530,
"message": "Macro evaluates parameter 'B' multiple times; use inline function instead",
"rule_id": "PRE12-C",
"severity": "Medium",
"suggestion": "Replace macro with inline function to avoid multiple evaluation"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lauxlib.c",
"line": 537,
"message": "Function-like macro 'checkbufferlevel' evaluates parameter(s) multiple times; prefer inline or static functions for type safety",
"rule_id": "PRE00-C",
"severity": "Low",
"suggestion": null
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lauxlib.c",
"line": 537,
"message": "Macro parameter 'B' is not parenthesized in replacement text. This can cause operator precedence issues.",
"rule_id": "PRE01-C",
"severity": "Medium",
"suggestion": "Wrap parameter 'B' in parentheses: (B) instead of B"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lauxlib.c",
"line": 537,
"message": "Macro replacement list should be parenthesized to prevent operator precedence issues.",
"rule_id": "PRE02-C",
"severity": "Medium",
"suggestion": "Wrap the entire replacement list in parentheses: (lua_assert(buffonstack(B) ? lua_touserdata(B->L, idx) != NULL \\\n : lua_touserdata(B->L, idx) == (void*)B))"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lauxlib.c",
"line": 537,
"message": "Macro evaluates parameter 'B' multiple times; use inline function instead",
"rule_id": "PRE12-C",
"severity": "Medium",
"suggestion": "Replace macro with inline function to avoid multiple evaluation"
},
{
"column": 40,
"file": "/home/brandon/toolchain/lua/lauxlib.c",
"line": 546,
"message": "Pointer parameter 'B' is not modified and should be declared const",
"rule_id": "DCL13-C",
"severity": "Low",
"suggestion": "Declare parameter as 'const <type> *B'"
},
{
"column": 5,
"file": "/home/brandon/toolchain/lua/lauxlib.c",
"line": 552,
"message": "Variable 'newsize' used with both bitwise and arithmetic operations (reduces code readability)",
"rule_id": "INT14-C",
"severity": "Medium",
"suggestion": "Use separate variables for bitwise and arithmetic operations, or refactor to use only arithmetic operators"
},
{
"column": 7,
"file": "/home/brandon/toolchain/lua/lauxlib.c",
"line": 581,
"message": "Function 'memcpy' called with potentially invalid size calculation",
"rule_id": "ARR38-C",
"severity": "High",
"suggestion": "Ensure size argument does not exceed buffer bounds"
},
{
"column": 7,
"file": "/home/brandon/toolchain/lua/lauxlib.c",
"line": 581,
"message": "memcpy() size argument contains arithmetic that may overflow: 'B->n * sizeof(char)'",
"rule_id": "INT32-C",
"severity": "High",
"suggestion": "Validate size calculations before passing to memory functions"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lauxlib.c",
"line": 592,
"message": "Function 'luaL_prepbuffsize' does not validate pointer parameter 'B' before use",
"rule_id": "API00-C",
"severity": "Medium",
"suggestion": "Add validation check for 'B' at the start of the function, e.g., 'if (!B) { return error_code; }'"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lauxlib.c",
"line": 597,
"message": "Function 'luaL_addlstring' should be declared static if it doesn't need external linkage",
"rule_id": "DCL15-C",
"severity": "Low",
"suggestion": "Add 'static' storage-class specifier: static LUALIB_API luaL_addlstring"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lauxlib.c",
"line": 597,
"message": "Function 'luaL_addlstring' is only used within this file. It should be declared static to minimize scope.",
"rule_id": "DCL19-C",
"severity": "Low",
"suggestion": "Add 'static' storage class to function 'luaL_addlstring'"
},
{
"column": 61,
"file": "/home/brandon/toolchain/lua/lauxlib.c",
"line": 597,
"message": "Pointer parameter should use conformant array syntax",
"rule_id": "API05-C",
"severity": "High",
"suggestion": "Use conformant array parameter syntax (e.g., 'char p[n]') with the size parameter declared before the array"
},
{
"column": 5,
"file": "/home/brandon/toolchain/lua/lauxlib.c",
"line": 600,
"message": "Function 'memcpy' called with potentially invalid size calculation",
"rule_id": "ARR38-C",
"severity": "High",
"suggestion": "Ensure size argument does not exceed buffer bounds"
},
{
"column": 12,
"file": "/home/brandon/toolchain/lua/lauxlib.c",
"line": 600,
"message": "Do not cast away const qualification: 'b'",
"rule_id": "EXP05-C",
"severity": "Medium",
"suggestion": "Ensure const-qualified objects are not modified through cast-away pointers"
},
{
"column": 12,
"file": "/home/brandon/toolchain/lua/lauxlib.c",
"line": 600,
"message": "Passing potentially null pointer 'b' to function",
"rule_id": "EXP34-C",
"severity": "High",
"suggestion": "Check if 'b' is not NULL before passing to function"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lauxlib.c",
"line": 606,
"message": "Function 'luaL_addstring' does not validate pointer parameter 'B' before use",
"rule_id": "API00-C",
"severity": "Medium",
"suggestion": "Add validation check for 'B' at the start of the function, e.g., 'if (!B) { return error_code; }'"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lauxlib.c",
"line": 606,
"message": "Function 'luaL_addstring' does not validate pointer parameter 's' before use",
"rule_id": "API00-C",
"severity": "Medium",
"suggestion": "Add validation check for 's' at the start of the function, e.g., 'if (!s) { return error_code; }'"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lauxlib.c",
"line": 606,
"message": "Function 'luaL_addstring' should be declared static if it doesn't need external linkage",
"rule_id": "DCL15-C",
"severity": "Low",
"suggestion": "Add 'static' storage-class specifier: static LUALIB_API luaL_addstring"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lauxlib.c",
"line": 606,
"message": "Function 'luaL_addstring' is only used within this file. It should be declared static to minimize scope.",
"rule_id": "DCL19-C",
"severity": "Low",
"suggestion": "Add 'static' storage class to function 'luaL_addstring'"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lauxlib.c",
"line": 611,
"message": "Function 'luaL_pushresult' does not validate pointer parameter 'B' before use",
"rule_id": "API00-C",
"severity": "Medium",
"suggestion": "Add validation check for 'B' at the start of the function, e.g., 'if (!B) { return error_code; }'"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lauxlib.c",
"line": 611,
"message": "Function 'luaL_pushresult' should be declared static if it doesn't need external linkage",
"rule_id": "DCL15-C",
"severity": "Low",
"suggestion": "Add 'static' storage-class specifier: static LUALIB_API luaL_pushresult"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lauxlib.c",
"line": 611,
"message": "Function 'luaL_pushresult' is only used within this file. It should be declared static to minimize scope.",
"rule_id": "DCL19-C",
"severity": "Low",
"suggestion": "Add 'static' storage class to function 'luaL_pushresult'"
},
{
"column": 16,
"file": "/home/brandon/toolchain/lua/lauxlib.c",
"line": 623,
"message": "Potential null pointer dereference in member access of variable 'box'",
"rule_id": "EXP34-C",
"severity": "High",
"suggestion": "Check if 'box' is not NULL before member access"
},
{
"column": 47,
"file": "/home/brandon/toolchain/lua/lauxlib.c",
"line": 627,
"message": "Variable 'ud' is used uninitialized",
"rule_id": "EXP33-C",
"severity": "High",
"suggestion": "Initialize 'ud' before use, e.g., at its declaration"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lauxlib.c",
"line": 635,
"message": "Function 'luaL_pushresultsize' does not validate pointer parameter 'B' before use",
"rule_id": "API00-C",
"severity": "Medium",
"suggestion": "Add validation check for 'B' at the start of the function, e.g., 'if (!B) { return error_code; }'"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lauxlib.c",
"line": 635,
"message": "Function 'luaL_pushresultsize' should be declared static if it doesn't need external linkage",
"rule_id": "DCL15-C",
"severity": "Low",
"suggestion": "Add 'static' storage-class specifier: static LUALIB_API luaL_pushresultsize"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lauxlib.c",
"line": 650,
"message": "Function 'luaL_addvalue' does not validate pointer parameter 'B' before use",
"rule_id": "API00-C",
"severity": "Medium",
"suggestion": "Add validation check for 'B' at the start of the function, e.g., 'if (!B) { return error_code; }'"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lauxlib.c",
"line": 650,
"message": "Function 'luaL_addvalue' should be declared static if it doesn't need external linkage",
"rule_id": "DCL15-C",
"severity": "Low",
"suggestion": "Add 'static' storage-class specifier: static LUALIB_API luaL_addvalue"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lauxlib.c",
"line": 650,
"message": "Function 'luaL_addvalue' is only used within this file. It should be declared static to minimize scope.",
"rule_id": "DCL19-C",
"severity": "Low",
"suggestion": "Add 'static' storage class to function 'luaL_addvalue'"
},
{
"column": 29,
"file": "/home/brandon/toolchain/lua/lauxlib.c",
"line": 654,
"message": "Variable 'len' is used uninitialized",
"rule_id": "EXP33-C",
"severity": "High",
"suggestion": "Initialize 'len' before use, e.g., at its declaration"
},
{
"column": 3,
"file": "/home/brandon/toolchain/lua/lauxlib.c",
"line": 655,
"message": "Function 'memcpy' called with potentially invalid size calculation",
"rule_id": "ARR38-C",
"severity": "High",
"suggestion": "Ensure size argument does not exceed buffer bounds"
},
{
"column": 10,
"file": "/home/brandon/toolchain/lua/lauxlib.c",
"line": 655,
"message": "Do not cast away const qualification: 'b'",
"rule_id": "EXP05-C",
"severity": "Medium",
"suggestion": "Ensure const-qualified objects are not modified through cast-away pointers"
},
{
"column": 10,
"file": "/home/brandon/toolchain/lua/lauxlib.c",
"line": 655,
"message": "Passing potentially null pointer 'b' to function",
"rule_id": "EXP34-C",
"severity": "High",
"suggestion": "Check if 'b' is not NULL before passing to function"
},
{
"column": 13,
"file": "/home/brandon/toolchain/lua/lauxlib.c",
"line": 655,
"message": "Passing potentially null pointer 's' to function",
"rule_id": "EXP34-C",
"severity": "High",
"suggestion": "Check if 's' is not NULL before passing to function"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lauxlib.c",
"line": 661,
"message": "Function 'luaL_buffinit' does not validate pointer parameter 'L' before use",
"rule_id": "API00-C",
"severity": "Medium",
"suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lauxlib.c",
"line": 661,
"message": "Function 'luaL_buffinit' does not validate pointer parameter 'B' before use",
"rule_id": "API00-C",
"severity": "Medium",
"suggestion": "Add validation check for 'B' at the start of the function, e.g., 'if (!B) { return error_code; }'"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lauxlib.c",
"line": 661,
"message": "Function 'luaL_buffinit' should be declared static if it doesn't need external linkage",
"rule_id": "DCL15-C",
"severity": "Low",
"suggestion": "Add 'static' storage-class specifier: static LUALIB_API luaL_buffinit"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lauxlib.c",
"line": 661,
"message": "Function 'luaL_buffinit' is only used within this file. It should be declared static to minimize scope.",
"rule_id": "DCL19-C",
"severity": "Low",
"suggestion": "Add 'static' storage class to function 'luaL_buffinit'"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lauxlib.c",
"line": 670,
"message": "Function 'luaL_buffinitsize' does not validate pointer parameter 'L' before use",
"rule_id": "API00-C",
"severity": "Medium",
"suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lauxlib.c",
"line": 670,
"message": "Function 'luaL_buffinitsize' does not validate pointer parameter 'B' before use",
"rule_id": "API00-C",
"severity": "Medium",
"suggestion": "Add validation check for 'B' at the start of the function, e.g., 'if (!B) { return error_code; }'"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lauxlib.c",
"line": 689,
"message": "Function 'luaL_ref' should be declared static if it doesn't need external linkage",
"rule_id": "DCL15-C",
"severity": "Low",
"suggestion": "Add 'static' storage-class specifier: static LUALIB_API luaL_ref"
},
{
"column": 16,
"file": "/home/brandon/toolchain/lua/lauxlib.c",
"line": 710,
"message": "Function 'lua_rawlen' is called without prior declaration",
"rule_id": "DCL31-C",
"severity": "Low",
"suggestion": "Declare the function before calling it or include the appropriate header"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lauxlib.c",
"line": 716,
"message": "Function 'luaL_unref' should be declared static if it doesn't need external linkage",
"rule_id": "DCL15-C",
"severity": "Low",
"suggestion": "Add 'static' storage-class specifier: static LUALIB_API luaL_unref"
},
{
"column": 45,
"file": "/home/brandon/toolchain/lua/lauxlib.c",
"line": 743,
"message": "Pointer parameter should use conformant array syntax",
"rule_id": "API05-C",
"severity": "High",
"suggestion": "Use conformant array parameter syntax (e.g., 'char p[n]') with the size parameter declared before the array"
},
{
"column": 13,
"file": "/home/brandon/toolchain/lua/lauxlib.c",
"line": 755,
"message": "Function 'fread' count parameter appears to use total size instead of element count",
"rule_id": "ARR38-C",
"severity": "High",
"suggestion": "Use element count, not total byte size. Example: fread(buf, sizeof(elem), count, file)"
},
{
"column": 13,
"file": "/home/brandon/toolchain/lua/lauxlib.c",
"line": 755,
"message": "fread() used without explicitly accounting for null terminator in character buffer",
"rule_id": "FIO17-C",
"severity": "Medium",
"suggestion": "Ensure buffer size accounts for null terminator, or explicitly add null terminator after fread()"
},
{
"column": 60,
"file": "/home/brandon/toolchain/lua/lauxlib.c",
"line": 765,
"message": "Call to non-thread-safe function 'strerror'. Use strerror_r() (POSIX) or strerror_s() (C11 Annex K) for thread-safe error reporting",
"rule_id": "CON33-C",
"severity": "Medium",
"suggestion": "Use strerror_r() (POSIX) or strerror_s() (C11 Annex K) for thread-safe error reporting"
},
{
"column": 60,
"file": "/home/brandon/toolchain/lua/lauxlib.c",
"line": 765,
"message": "'strerror()' uses internal static storage that is shared between threads",
"rule_id": "CON34-C",
"severity": "Medium",
"suggestion": "Use 'strerror_r' instead for thread safety"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lauxlib.c",
"line": 779,
"message": "Non-void function may reach end without returning a value. Ensure all execution paths have explicit return statements.",
"rule_id": "MSC37-C",
"severity": "Medium",
"suggestion": "Add return statements to ensure all execution paths return a value"
},
{
"column": 3,
"file": "/home/brandon/toolchain/lua/lauxlib.c",
"line": 780,
"message": "Variable 'c' is initialized but never modified, consider const-qualifying it",
"rule_id": "DCL00-C",
"severity": "Medium",
"suggestion": "Add 'const' qualifier: const c = ..."
},
{
"column": 3,
"file": "/home/brandon/toolchain/lua/lauxlib.c",
"line": 796,
"message": "Variable 'c' is initialized but never modified, consider const-qualifying it",
"rule_id": "DCL00-C",
"severity": "Medium",
"suggestion": "Add 'const' qualifier: const c = ..."
},
{
"column": 5,
"file": "/home/brandon/toolchain/lua/lauxlib.c",
"line": 798,
"message": "EOF comparison without feof()/ferror() verification: 'do { /* skip first line */'",
"rule_id": "FIO34-C",
"severity": "High",
"suggestion": "After EOF is detected, call feof() and ferror() to distinguish between end-of-file and I/O error"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lauxlib.c",
"line": 808,
"message": "Function 'luaL_loadfilex' does not validate pointer parameter 'L' before use",
"rule_id": "API00-C",
"severity": "Medium",
"suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lauxlib.c",
"line": 808,
"message": "Function 'luaL_loadfilex' does not validate pointer parameter 'mode' before use",
"rule_id": "API00-C",
"severity": "Medium",
"suggestion": "Add validation check for 'mode' at the start of the function, e.g., 'if (!mode) { return error_code; }'"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lauxlib.c",
"line": 808,
"message": "Function 'luaL_loadfilex' should be declared static if it doesn't need external linkage",
"rule_id": "DCL15-C",
"severity": "Low",
"suggestion": "Add 'static' storage-class specifier: static LUALIB_API luaL_loadfilex"
},
{
"column": 6,
"file": "/home/brandon/toolchain/lua/lauxlib.c",
"line": 814,
"message": "Direct NULL check for pointer validation. Define and use a dedicated pointer validation function instead of ad-hoc NULL checks. This centralizes validation logic and allows platform-specific enhancements.",
"rule_id": "MEM10-C",
"severity": "Medium",
"suggestion": "Create a validation function like 'int valid(void *ptr)' and use 'if (!valid(ptr))' instead of 'if (ptr == NULL)'"
},
{
"column": 12,
"file": "/home/brandon/toolchain/lua/lauxlib.c",
"line": 821,
"message": "File opened for reading using variable filename 'filename' without verifying file attributes (fstat + st_uid/st_gid check)",
"rule_id": "FIO05-C",
"severity": "Medium",
"suggestion": "Use fstat() to check file ownership (st_uid, st_gid) before reading untrusted files"
},
{
"column": 12,
"file": "/home/brandon/toolchain/lua/lauxlib.c",
"line": 821,
"message": "fopen() called without 'N' flag in mode string \"r\". On Windows, file handles are inheritable by default unless the 'N' flag is specified.",
"rule_id": "WIN03-C",
"severity": "High",
"suggestion": "Add 'N' flag to the mode string (e.g., \"rwN\") to disable handle inheritance on Windows."
},
{
"column": 7,
"file": "/home/brandon/toolchain/lua/lauxlib.c",
"line": 827,
"message": "Variable 'c' is used uninitialized",
"rule_id": "EXP33-C",
"severity": "High",
"suggestion": "Initialize 'c' before use, e.g., at its declaration"
},
{
"column": 7,
"file": "/home/brandon/toolchain/lua/lauxlib.c",
"line": 831,
"message": "Return value of 'freopen' assigned to 'lf.f' but not checked for errors: 'freopen(filename, \"rb\", lf.f)' - Can return error indicator",
"rule_id": "ERR33-C",
"severity": "High",
"suggestion": "Check return value for errors"
},
{
"column": 25,
"file": "/home/brandon/toolchain/lua/lauxlib.c",
"line": 832,
"message": "Function returns without releasing all resources. Leaked: lf.f, lf.f. Consider using goto chain for proper resource cleanup.",
"rule_id": "MEM12-C",
"severity": "Low",
"suggestion": "Use goto chain pattern with cleanup labels to ensure all resources are released"
},
{
"column": 17,
"file": "/home/brandon/toolchain/lua/lauxlib.c",
"line": 841,
"message": "Return value from fclose() is ignored. Error handling is required.",
"rule_id": "ERR00-C",
"severity": "Medium",
"suggestion": "Store and check the return value from fclose()"
},
{
"column": 17,
"file": "/home/brandon/toolchain/lua/lauxlib.c",
"line": 841,
"message": "Return value of 'fclose' ignored: 'fclose(lf.f)' - Returns non-zero on error",
"rule_id": "ERR33-C",
"severity": "High",
"suggestion": "Check if (fclose(file) != 0) for close errors"
},
{
"column": 45,
"file": "/home/brandon/toolchain/lua/lauxlib.c",
"line": 857,
"message": "Pointer parameter should use conformant array syntax",
"rule_id": "API05-C",
"severity": "High",
"suggestion": "Use conformant array parameter syntax (e.g., 'char p[n]') with the size parameter declared before the array"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lauxlib.c",
"line": 867,
"message": "Function 'luaL_loadbufferx' does not validate pointer parameter 'L' before use",
"rule_id": "API00-C",
"severity": "Medium",
"suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lauxlib.c",
"line": 867,
"message": "Function 'luaL_loadbufferx' does not validate pointer parameter 'buff' before use",
"rule_id": "API00-C",
"severity": "Medium",
"suggestion": "Add validation check for 'buff' at the start of the function, e.g., 'if (!buff) { return error_code; }'"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lauxlib.c",
"line": 867,
"message": "Function 'luaL_loadbufferx' does not validate pointer parameter 'mode' before use",
"rule_id": "API00-C",
"severity": "Medium",
"suggestion": "Add validation check for 'mode' at the start of the function, e.g., 'if (!mode) { return error_code; }'"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lauxlib.c",
"line": 867,
"message": "Function 'luaL_loadbufferx' should be declared static if it doesn't need external linkage",
"rule_id": "DCL15-C",
"severity": "Low",
"suggestion": "Add 'static' storage-class specifier: static LUALIB_API luaL_loadbufferx"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lauxlib.c",
"line": 867,
"message": "Function 'luaL_loadbufferx' is only used within this file. It should be declared static to minimize scope.",
"rule_id": "DCL19-C",
"severity": "Low",
"suggestion": "Add 'static' storage class to function 'luaL_loadbufferx'"
},
{
"column": 59,
"file": "/home/brandon/toolchain/lua/lauxlib.c",
"line": 867,
"message": "Pointer parameter should use conformant array syntax",
"rule_id": "API05-C",
"severity": "High",
"suggestion": "Use conformant array parameter syntax (e.g., 'char p[n]') with the size parameter declared before the array"
},
{
"column": 45,
"file": "/home/brandon/toolchain/lua/lauxlib.c",
"line": 868,
"message": "Pointer parameter should use conformant array syntax",
"rule_id": "API05-C",
"severity": "High",
"suggestion": "Use conformant array parameter syntax (e.g., 'char p[n]') with the size parameter declared before the array"
},
{
"column": 63,
"file": "/home/brandon/toolchain/lua/lauxlib.c",
"line": 868,
"message": "Pointer parameter should use conformant array syntax",
"rule_id": "API05-C",
"severity": "High",
"suggestion": "Use conformant array parameter syntax (e.g., 'char p[n]') with the size parameter declared before the array"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lauxlib.c",
"line": 876,
"message": "Function 'luaL_loadstring' does not validate pointer parameter 'L' before use",
"rule_id": "API00-C",
"severity": "Medium",
"suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lauxlib.c",
"line": 876,
"message": "Function 'luaL_loadstring' does not validate pointer parameter 's' before use",
"rule_id": "API00-C",
"severity": "Medium",
"suggestion": "Add validation check for 's' at the start of the function, e.g., 'if (!s) { return error_code; }'"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lauxlib.c",
"line": 876,
"message": "Function 'luaL_loadstring' should be declared static if it doesn't need external linkage",
"rule_id": "DCL15-C",
"severity": "Low",
"suggestion": "Add 'static' storage-class specifier: static LUALIB_API luaL_loadstring"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lauxlib.c",
"line": 884,
"message": "Function 'luaL_getmetafield' should be declared static if it doesn't need external linkage",
"rule_id": "DCL15-C",
"severity": "Low",
"suggestion": "Add 'static' storage-class specifier: static LUALIB_API luaL_getmetafield"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lauxlib.c",
"line": 884,
"message": "Function 'luaL_getmetafield' is only used within this file. It should be declared static to minimize scope.",
"rule_id": "DCL19-C",
"severity": "Low",
"suggestion": "Add 'static' storage class to function 'luaL_getmetafield'"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lauxlib.c",
"line": 900,
"message": "Function 'luaL_callmeta' should be declared static if it doesn't need external linkage",
"rule_id": "DCL15-C",
"severity": "Low",
"suggestion": "Add 'static' storage-class specifier: static LUALIB_API luaL_callmeta"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lauxlib.c",
"line": 900,
"message": "Function 'luaL_callmeta' is only used within this file. It should be declared static to minimize scope.",
"rule_id": "DCL19-C",
"severity": "Low",
"suggestion": "Add 'static' storage class to function 'luaL_callmeta'"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lauxlib.c",
"line": 910,
"message": "Function 'lua_Integer' does not validate pointer parameter 'L' before use",
"rule_id": "API00-C",
"severity": "Medium",
"suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lauxlib.c",
"line": 922,
"message": "Function 'luaL_tolstring' does not validate pointer parameter 'L' before use",
"rule_id": "API00-C",
"severity": "Medium",
"suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lauxlib.c",
"line": 965,
"message": "Function 'luaL_setfuncs' does not validate pointer parameter 'L' before use",
"rule_id": "API00-C",
"severity": "Medium",
"suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lauxlib.c",
"line": 965,
"message": "Function 'luaL_setfuncs' does not validate pointer parameter 'l' before use",
"rule_id": "API00-C",
"severity": "Medium",
"suggestion": "Add validation check for 'l' at the start of the function, e.g., 'if (!l) { return error_code; }'"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lauxlib.c",
"line": 965,
"message": "Function 'luaL_setfuncs' does not validate integer parameter 'nup' for overflow before arithmetic operations",
"rule_id": "API00-C",
"severity": "Medium",
"suggestion": "Add overflow validation for 'nup' before arithmetic, e.g., check against INT_MAX/INT_MIN or use __builtin_*_overflow()"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lauxlib.c",
"line": 965,
"message": "Function 'luaL_setfuncs' should be declared static if it doesn't need external linkage",
"rule_id": "DCL15-C",
"severity": "Low",
"suggestion": "Add 'static' storage-class specifier: static LUALIB_API luaL_setfuncs"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lauxlib.c",
"line": 965,
"message": "Function 'luaL_setfuncs' is only used within this file. It should be declared static to minimize scope.",
"rule_id": "DCL19-C",
"severity": "Low",
"suggestion": "Add 'static' storage class to function 'luaL_setfuncs'"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lauxlib.c",
"line": 986,
"message": "Function 'luaL_getsubtable' should be declared static if it doesn't need external linkage",
"rule_id": "DCL15-C",
"severity": "Low",
"suggestion": "Add 'static' storage-class specifier: static LUALIB_API luaL_getsubtable"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lauxlib.c",
"line": 986,
"message": "Function 'luaL_getsubtable' is only used within this file. It should be declared static to minimize scope.",
"rule_id": "DCL19-C",
"severity": "Low",
"suggestion": "Add 'static' storage class to function 'luaL_getsubtable'"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lauxlib.c",
"line": 1006,
"message": "Function 'luaL_requiref' does not validate pointer parameter 'L' before use",
"rule_id": "API00-C",
"severity": "Medium",
"suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lauxlib.c",
"line": 1006,
"message": "Function 'luaL_requiref' does not validate pointer parameter 'modname' before use",
"rule_id": "API00-C",
"severity": "Medium",
"suggestion": "Add validation check for 'modname' at the start of the function, e.g., 'if (!modname) { return error_code; }'"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lauxlib.c",
"line": 1006,
"message": "Function 'luaL_requiref' should be declared static if it doesn't need external linkage",
"rule_id": "DCL15-C",
"severity": "Low",
"suggestion": "Add 'static' storage-class specifier: static LUALIB_API luaL_requiref"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lauxlib.c",
"line": 1026,
"message": "Function 'luaL_addgsub' does not validate pointer parameter 'b' before use",
"rule_id": "API00-C",
"severity": "Medium",
"suggestion": "Add validation check for 'b' at the start of the function, e.g., 'if (!b) { return error_code; }'"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lauxlib.c",
"line": 1026,
"message": "Function 'luaL_addgsub' does not validate pointer parameter 's' before use",
"rule_id": "API00-C",
"severity": "Medium",
"suggestion": "Add validation check for 's' at the start of the function, e.g., 'if (!s) { return error_code; }'"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lauxlib.c",
"line": 1026,
"message": "Function 'luaL_addgsub' does not validate pointer parameter 'p' before use",
"rule_id": "API00-C",
"severity": "Medium",
"suggestion": "Add validation check for 'p' at the start of the function, e.g., 'if (!p) { return error_code; }'"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lauxlib.c",
"line": 1026,
"message": "Function 'luaL_addgsub' does not validate pointer parameter 'r' before use",
"rule_id": "API00-C",
"severity": "Medium",
"suggestion": "Add validation check for 'r' at the start of the function, e.g., 'if (!r) { return error_code; }'"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lauxlib.c",
"line": 1026,
"message": "Function 'luaL_addgsub' should be declared static if it doesn't need external linkage",
"rule_id": "DCL15-C",
"severity": "Low",
"suggestion": "Add 'static' storage-class specifier: static LUALIB_API luaL_addgsub"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lauxlib.c",
"line": 1026,
"message": "Function 'luaL_addgsub' is only used within this file. It should be declared static to minimize scope.",
"rule_id": "DCL19-C",
"severity": "Low",
"suggestion": "Add 'static' storage class to function 'luaL_addgsub'"
},
{
"column": 21,
"file": "/home/brandon/toolchain/lua/lauxlib.c",
"line": 1029,
"message": "'p' (signed/plain char) converted to larger integer type without cast to 'unsigned char' - may cause sign extension",
"rule_id": "STR34-C",
"severity": "Medium",
"suggestion": "Cast to 'unsigned char' before conversion to larger type"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lauxlib.c",
"line": 1039,
"message": "Function 'luaL_gsub' does not validate pointer parameter 'L' before use",
"rule_id": "API00-C",
"severity": "Medium",
"suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lauxlib.c",
"line": 1039,
"message": "Function 'luaL_gsub' does not validate pointer parameter 's' before use",
"rule_id": "API00-C",
"severity": "Medium",
"suggestion": "Add validation check for 's' at the start of the function, e.g., 'if (!s) { return error_code; }'"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lauxlib.c",
"line": 1039,
"message": "Function 'luaL_gsub' does not validate pointer parameter 'p' before use",
"rule_id": "API00-C",
"severity": "Medium",
"suggestion": "Add validation check for 'p' at the start of the function, e.g., 'if (!p) { return error_code; }'"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lauxlib.c",
"line": 1039,
"message": "Function 'luaL_gsub' does not validate pointer parameter 'r' before use",
"rule_id": "API00-C",
"severity": "Medium",
"suggestion": "Add validation check for 'r' at the start of the function, e.g., 'if (!r) { return error_code; }'"
},
{
"column": 24,
"file": "/home/brandon/toolchain/lua/lauxlib.c",
"line": 1049,
"message": "Pointer parameter should use conformant array syntax",
"rule_id": "API05-C",
"severity": "High",
"suggestion": "Use conformant array parameter syntax (e.g., 'char p[n]') with the size parameter declared before the array"
},
{
"column": 34,
"file": "/home/brandon/toolchain/lua/lauxlib.c",
"line": 1049,
"message": "Pointer parameter should use conformant array syntax",
"rule_id": "API05-C",
"severity": "High",
"suggestion": "Use conformant array parameter syntax (e.g., 'char p[n]') with the size parameter declared before the array"
},
{
"column": 5,
"file": "/home/brandon/toolchain/lua/lauxlib.c",
"line": 1052,
"message": "Pointer 'ptr' freed without clearing sensitive data first",
"rule_id": "MEM03-C",
"severity": "Medium",
"suggestion": "Add 'memset(ptr, 0, size);' before free(ptr) to clear sensitive data"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lauxlib.c",
"line": 1056,
"message": "Mixed string management approaches detected. Static char array at line 931 and dynamic allocation at line 1056. Consider adopting a consistent approach.",
"rule_id": "STR01-C",
"severity": "Low",
"suggestion": "Adopt either static string arrays OR dynamic allocation consistently throughout the codebase. Document the chosen approach in coding standards."
},
{
"column": 12,
"file": "/home/brandon/toolchain/lua/lauxlib.c",
"line": 1056,
"message": "Sensitive data allocated with realloc may be written to disk. Use mlock() (POSIX) or VirtualLock() (Windows) to lock memory pages, or use setrlimit(RLIMIT_CORE, 0) to disable core dumps.",
"rule_id": "MEM06-C",
"severity": "Medium",
"suggestion": "Consider using mlock()/munlock() to prevent memory from being swapped to disk, or use setrlimit() to disable core dumps."
},
{
"column": 7,
"file": "/home/brandon/toolchain/lua/lauxlib.c",
"line": 1094,
"message": "Function 'lua_setwarnf' called with same pointer for output and input parameters. If output parameter is non-const restrict, this causes undefined behavior.",
"rule_id": "EXP43-C",
"severity": "High",
"suggestion": "Ensure output restrict parameter receives a unique pointer"
},
{
"column": 7,
"file": "/home/brandon/toolchain/lua/lauxlib.c",
"line": 1096,
"message": "Function 'lua_setwarnf' called with same pointer for output and input parameters. If output parameter is non-const restrict, this causes undefined behavior.",
"rule_id": "EXP43-C",
"severity": "High",
"suggestion": "Ensure output restrict parameter receives a unique pointer"
},
{
"column": 5,
"file": "/home/brandon/toolchain/lua/lauxlib.c",
"line": 1115,
"message": "Function 'lua_setwarnf' called with same pointer for output and input parameters. If output parameter is non-const restrict, this causes undefined behavior.",
"rule_id": "EXP43-C",
"severity": "High",
"suggestion": "Ensure output restrict parameter receives a unique pointer"
},
{
"column": 5,
"file": "/home/brandon/toolchain/lua/lauxlib.c",
"line": 1118,
"message": "Function 'lua_setwarnf' called with same pointer for output and input parameters. If output parameter is non-const restrict, this causes undefined behavior.",
"rule_id": "EXP43-C",
"severity": "High",
"suggestion": "Ensure output restrict parameter receives a unique pointer"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lauxlib.c",
"line": 1152,
"message": "Function-like macro 'addbuff' evaluates parameter(s) multiple times; prefer inline or static functions for type safety",
"rule_id": "PRE00-C",
"severity": "Low",
"suggestion": null
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lauxlib.c",
"line": 1152,
"message": "Macro parameter 'b' is not parenthesized in replacement text. This can cause operator precedence issues.",
"rule_id": "PRE01-C",
"severity": "Medium",
"suggestion": "Wrap parameter 'b' in parentheses: (b) instead of b"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lauxlib.c",
"line": 1152,
"message": "Macro evaluates parameter 'b' multiple times; use inline function instead",
"rule_id": "PRE12-C",
"severity": "Medium",
"suggestion": "Replace macro with inline function to avoid multiple evaluation"
},
{
"column": 10,
"file": "/home/brandon/toolchain/lua/lauxlib.c",
"line": 1159,
"message": "Return value of 'time' assigned to 't' but not checked for errors: 'time(NULL)' - Returns (time_t)(-1) on failure",
"rule_id": "ERR33-C",
"severity": "High",
"suggestion": "Check if (result == (time_t)(-1)) for time errors"
},
{
"column": 20,
"file": "/home/brandon/toolchain/lua/lauxlib.c",
"line": 1160,
"message": "Variable 'buff' is used uninitialized",
"rule_id": "EXP33-C",
"severity": "High",
"suggestion": "Initialize 'buff' before use, e.g., at its declaration"
},
{
"column": 3,
"file": "/home/brandon/toolchain/lua/lauxlib.c",
"line": 1161,
"message": "Function 'addbuff' called with same pointer for output and input parameters. If output parameter is non-const restrict, this causes undefined behavior.",
"rule_id": "EXP43-C",
"severity": "High",
"suggestion": "Ensure output restrict parameter receives a unique pointer"
},
{
"column": 3,
"file": "/home/brandon/toolchain/lua/lauxlib.c",
"line": 1164,
"message": "memset() size argument contains arithmetic that may overflow: 'sizeof(buff) - BUFSEEDB'",
"rule_id": "INT32-C",
"severity": "High",
"suggestion": "Validate size calculations before passing to memory functions"
},
{
"column": 10,
"file": "/home/brandon/toolchain/lua/lauxlib.c",
"line": 1164,
"message": "Do not cast away const qualification: 'b'",
"rule_id": "EXP05-C",
"severity": "Medium",
"suggestion": "Ensure const-qualified objects are not modified through cast-away pointers"
},
{
"column": 5,
"file": "/home/brandon/toolchain/lua/lauxlib.c",
"line": 1167,
"message": "Variable 'res' used with both bitwise and arithmetic operations (reduces code readability)",
"rule_id": "INT14-C",
"severity": "Medium",
"suggestion": "Use separate variables for bitwise and arithmetic operations, or refactor to use only arithmetic operators"
},
{
"column": 26,
"file": "/home/brandon/toolchain/lua/lauxlib.c",
"line": 1167,
"message": "Output operation on file stream 'res' follows input without intervening positioning call (fseek, fsetpos, or rewind)",
"rule_id": "FIO50-C",
"severity": "Low",
"suggestion": "Insert a positioning function (fseek, fsetpos, rewind) between input and output operations, unless input encountered EOF"
},
{
"column": 26,
"file": "/home/brandon/toolchain/lua/lauxlib.c",
"line": 1167,
"message": "Output operation on file stream 'res' follows input without intervening positioning call (fseek, fsetpos, or rewind)",
"rule_id": "FIO50-C",
"severity": "Low",
"suggestion": "Insert a positioning function (fseek, fsetpos, rewind) between input and output operations, unless input encountered EOF"
},
{
"column": 38,
"file": "/home/brandon/toolchain/lua/lauxlib.c",
"line": 1167,
"message": "Reading from uninitialized array 'buff' inside a loop. Array was declared but never initialized before being read.",
"rule_id": "ARR00-C",
"severity": "Medium",
"suggestion": "Initialize array 'buff' before reading: int buff[N] = {0}; or assign values before use"
},
{
"column": 5,
"file": "/home/brandon/toolchain/lua/lauxlib.c",
"line": 1187,
"message": "Function 'lua_atpanic' is called without prior declaration",
"rule_id": "DCL31-C",
"severity": "Low",
"suggestion": "Declare the function before calling it or include the appropriate header"
},
{
"column": 5,
"file": "/home/brandon/toolchain/lua/lauxlib.c",
"line": 1188,
"message": "Function 'lua_setwarnf' called with same pointer for output and input parameters. If output parameter is non-const restrict, this causes undefined behavior.",
"rule_id": "EXP43-C",
"severity": "High",
"suggestion": "Ensure output restrict parameter receives a unique pointer"
},
{
"column": 3,
"file": "/home/brandon/toolchain/lua/lauxlib.c",
"line": 1190,
"message": "Function returns pointer to local variable 'L' with automatic storage duration",
"rule_id": "DCL30-C",
"severity": "High",
"suggestion": "Use static storage, allocated memory, or pass output buffer as parameter"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lauxlib.c",
"line": 1194,
"message": "Function 'luaL_checkversion_' does not validate pointer parameter 'L' before use",
"rule_id": "API00-C",
"severity": "Medium",
"suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lauxlib.c",
"line": 1194,
"message": "Function 'luaL_checkversion_' should be declared static if it doesn't need external linkage",
"rule_id": "DCL15-C",
"severity": "Low",
"suggestion": "Add 'static' storage-class specifier: static LUALIB_API luaL_checkversion_"
}
],
"ldo.c": [
{
"column": 33,
"file": "/home/brandon/toolchain/lua/ldo.c",
"line": 81,
"message": "Pointer parameter 'L' is not modified and should be declared const",
"rule_id": "DCL13-C",
"severity": "Low",
"suggestion": "Declare parameter as 'const <type> *L'"
},
{
"column": 49,
"file": "/home/brandon/toolchain/lua/ldo.c",
"line": 81,
"message": "Pointer parameter 'c' is not modified and should be declared const",
"rule_id": "DCL13-C",
"severity": "Low",
"suggestion": "Declare parameter as 'const <type> *c'"
},
{
"column": 67,
"file": "/home/brandon/toolchain/lua/ldo.c",
"line": 81,
"message": "Pointer parameter 'ud' is not modified and should be declared const",
"rule_id": "DCL13-C",
"severity": "Low",
"suggestion": "Declare parameter as 'const <type> *ud'"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/ldo.c",
"line": 99,
"message": "Macro replacement list should be parenthesized to prevent operator precedence issues.",
"rule_id": "PRE02-C",
"severity": "Medium",
"suggestion": "Wrap the entire replacement list in parentheses: (if (_setjmp((c)->b) == 0) ((f)(L, ud)))"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/ldo.c",
"line": 105,
"message": "Macro replacement list should be parenthesized to prevent operator precedence issues.",
"rule_id": "PRE02-C",
"severity": "Medium",
"suggestion": "Wrap the entire replacement list in parentheses: (if (setjmp((c)->b) == 0) ((f)(L, ud)))"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/ldo.c",
"line": 112,
"message": "Function 'luaD_seterrorobj' does not validate pointer parameter 'L' before use",
"rule_id": "API00-C",
"severity": "Medium",
"suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/ldo.c",
"line": 125,
"message": "Function 'luaD_throw' does not validate pointer parameter 'L' before use",
"rule_id": "API00-C",
"severity": "Medium",
"suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/ldo.c",
"line": 125,
"message": "Recursive function can cause excessive stack allocation",
"rule_id": "MEM05-C",
"severity": "Medium",
"suggestion": "Consider iterative approach or limit recursion depth"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/ldo.c",
"line": 125,
"message": "Function 'luaD_throw' calls itself directly (direct recursion)",
"rule_id": "MSC04-C",
"severity": "Medium",
"suggestion": "Refactor to use iteration instead of recursion"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/ldo.c",
"line": 125,
"message": "Non-void function has no return statement. Control reaching the end of a non-void function without returning a value is undefined behavior.",
"rule_id": "MSC37-C",
"severity": "Medium",
"suggestion": "Add a return statement on all execution paths of this function"
},
{
"column": 5,
"file": "/home/brandon/toolchain/lua/ldo.c",
"line": 131,
"message": "Variable 'g' is initialized but never modified, consider const-qualifying it",
"rule_id": "DCL00-C",
"severity": "Medium",
"suggestion": "Add 'const' qualifier: const g = ..."
},
{
"column": 7,
"file": "/home/brandon/toolchain/lua/ldo.c",
"line": 144,
"message": "Function 'luaD_throw' calls 'abort', which dictates error handling. Application-independent code should report errors to the caller (via return values, error parameters, or error indicators) rather than terminating the program.",
"rule_id": "ERR05-C",
"severity": "Medium",
"suggestion": "Replace 'abort' with error reporting via return value (e.g., 'return ERROR_CODE;'), error parameter (e.g., '*err = ERROR_CODE;'), or global error indicator"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/ldo.c",
"line": 150,
"message": "Function 'luaD_throwbaselevel' does not validate pointer parameter 'L' before use",
"rule_id": "API00-C",
"severity": "Medium",
"suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/ldo.c",
"line": 150,
"message": "Non-void function has no return statement. Control reaching the end of a non-void function without returning a value is undefined behavior.",
"rule_id": "MSC37-C",
"severity": "Medium",
"suggestion": "Add a return statement on all execution paths of this function"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/ldo.c",
"line": 160,
"message": "Function 'luaD_rawrunprotected' does not validate pointer parameter 'L' before use",
"rule_id": "API00-C",
"severity": "Medium",
"suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/ldo.c",
"line": 160,
"message": "Function 'luaD_rawrunprotected' does not validate pointer parameter 'ud' before use",
"rule_id": "API00-C",
"severity": "Medium",
"suggestion": "Add validation check for 'ud' at the start of the function, e.g., 'if (!ud) { return error_code; }'"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/ldo.c",
"line": 215,
"message": "Function 'luaD_errerr' does not validate pointer parameter 'L' before use",
"rule_id": "API00-C",
"severity": "Medium",
"suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/ldo.c",
"line": 215,
"message": "Non-void function has no return statement. Control reaching the end of a non-void function without returning a value is undefined behavior.",
"rule_id": "MSC37-C",
"severity": "Medium",
"suggestion": "Add a return statement on all execution paths of this function"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/ldo.c",
"line": 228,
"message": "Function 'luaD_checkminstack' participates in indirect recursion: luaD_checkminstack -> luaD_growstack -> luaG_runerror -> luaG_errormsg -> luaD_callnoyield -> ccall -> luaD_precall -> tryfuncTM -> luaG_callerror -> typeerror -> luaT_objtypename -> luaS_new -> luaS_newlstr -> internshrstr -> growstrtab -> luaC_fullgc -> fullgen -> entergen -> atomic2gen -> finishgencycle -> luaD_checkminstack",
"rule_id": "MSC04-C",
"severity": "Medium",
"suggestion": "Refactor to eliminate the recursion cycle"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/ldo.c",
"line": 228,
"message": "Non-void function may reach end without returning a value. Ensure all execution paths have explicit return statements.",
"rule_id": "MSC37-C",
"severity": "Medium",
"suggestion": "Add return statements to ensure all execution paths return a value"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/ldo.c",
"line": 330,
"message": "Function 'luaD_reallocstack' does not validate pointer parameter 'L' before use",
"rule_id": "API00-C",
"severity": "Medium",
"suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/ldo.c",
"line": 330,
"message": "Function 'luaD_reallocstack' does not validate integer parameter 'newsize' for overflow before arithmetic operations",
"rule_id": "API00-C",
"severity": "Medium",
"suggestion": "Add overflow validation for 'newsize' before arithmetic, e.g., check against INT_MAX/INT_MIN or use __builtin_*_overflow()"
},
{
"column": 3,
"file": "/home/brandon/toolchain/lua/ldo.c",
"line": 341,
"message": "Use-after-free: passing freed pointer 'L' to function",
"rule_id": "MEM30-C",
"severity": "Critical",
"suggestion": "Do not pass freed memory to functions."
},
{
"column": 5,
"file": "/home/brandon/toolchain/lua/ldo.c",
"line": 343,
"message": "Use-after-free: passing freed pointer 'L' to function",
"rule_id": "MEM30-C",
"severity": "Critical",
"suggestion": "Do not pass freed memory to functions."
},
{
"column": 5,
"file": "/home/brandon/toolchain/lua/ldo.c",
"line": 343,
"message": "Use-after-free: passing freed pointer 'oldstack' to function",
"rule_id": "MEM30-C",
"severity": "Critical",
"suggestion": "Do not pass freed memory to functions."
},
{
"column": 7,
"file": "/home/brandon/toolchain/lua/ldo.c",
"line": 345,
"message": "Use-after-free: passing freed pointer 'L' to function",
"rule_id": "MEM30-C",
"severity": "Critical",
"suggestion": "Do not pass freed memory to functions."
},
{
"column": 3,
"file": "/home/brandon/toolchain/lua/ldo.c",
"line": 349,
"message": "Use-after-free: passing freed pointer 'oldstack' to function",
"rule_id": "MEM30-C",
"severity": "Critical",
"suggestion": "Do not pass freed memory to functions."
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/ldo.c",
"line": 361,
"message": "Function 'luaD_growstack' does not validate pointer parameter 'L' before use",
"rule_id": "API00-C",
"severity": "Medium",
"suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/ldo.c",
"line": 361,
"message": "Function 'luaD_growstack' participates in indirect recursion: luaD_growstack -> luaG_runerror -> luaG_errormsg -> luaD_callnoyield -> ccall -> luaD_precall -> tryfuncTM -> luaG_callerror -> typeerror -> luaT_objtypename -> luaS_new -> luaS_newlstr -> internshrstr -> growstrtab -> luaC_fullgc -> fullgen -> entergen -> atomic2gen -> finishgencycle -> luaD_checkminstack -> luaD_growstack",
"rule_id": "MSC04-C",
"severity": "Medium",
"suggestion": "Refactor to eliminate the recursion cycle"
},
{
"column": 19,
"file": "/home/brandon/toolchain/lua/ldo.c",
"line": 373,
"message": "Variable 'size' used with both bitwise and arithmetic operations (reduces code readability)",
"rule_id": "INT14-C",
"severity": "Medium",
"suggestion": "Use separate variables for bitwise and arithmetic operations, or refactor to use only arithmetic operators"
},
{
"column": 27,
"file": "/home/brandon/toolchain/lua/ldo.c",
"line": 373,
"message": "Bitwise operator '>>' used on signed operand 'size' of type 'int'. Use unsigned types for bitwise operations",
"rule_id": "INT13-C",
"severity": "Medium",
"suggestion": "Change 'size' to an unsigned type (e.g., 'unsigned int' instead of 'int')"
},
{
"column": 5,
"file": "/home/brandon/toolchain/lua/ldo.c",
"line": 386,
"message": "Use-after-free: passing freed pointer 'L' to function",
"rule_id": "MEM30-C",
"severity": "Critical",
"suggestion": "Do not pass freed memory to functions."
},
{
"column": 34,
"file": "/home/brandon/toolchain/lua/ldo.c",
"line": 395,
"message": "Pointer parameter 'L' is not modified and should be declared const",
"rule_id": "DCL13-C",
"severity": "Low",
"suggestion": "Declare parameter as 'const <type> *L'"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/ldo.c",
"line": 419,
"message": "Function 'luaD_shrinkstack' does not validate pointer parameter 'L' before use",
"rule_id": "API00-C",
"severity": "Medium",
"suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"
},
{
"column": 3,
"file": "/home/brandon/toolchain/lua/ldo.c",
"line": 430,
"message": "Use-after-free: passing freed pointer 'L' to function",
"rule_id": "MEM30-C",
"severity": "Critical",
"suggestion": "Do not pass freed memory to functions."
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/ldo.c",
"line": 441,
"message": "Function 'luaD_hook' does not validate pointer parameter 'L' before use",
"rule_id": "API00-C",
"severity": "Medium",
"suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/ldo.c",
"line": 478,
"message": "Function 'luaD_hookcall' does not validate pointer parameter 'L' before use",
"rule_id": "API00-C",
"severity": "Medium",
"suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/ldo.c",
"line": 478,
"message": "Function 'luaD_hookcall' does not validate pointer parameter 'ci' before use",
"rule_id": "API00-C",
"severity": "Medium",
"suggestion": "Add validation check for 'ci' at the start of the function, e.g., 'if (!ci) { return error_code; }'"
},
{
"column": 7,
"file": "/home/brandon/toolchain/lua/ldo.c",
"line": 497,
"message": "Variable 'L' used with both bitwise and arithmetic operations (reduces code readability)",
"rule_id": "INT14-C",
"severity": "Medium",
"suggestion": "Use separate variables for bitwise and arithmetic operations, or refactor to use only arithmetic operators"
},
{
"column": 11,
"file": "/home/brandon/toolchain/lua/ldo.c",
"line": 503,
"message": "Variable 'p' used with both bitwise and arithmetic operations (reduces code readability)",
"rule_id": "INT14-C",
"severity": "Medium",
"suggestion": "Use separate variables for bitwise and arithmetic operations, or refactor to use only arithmetic operators"
},
{
"column": 7,
"file": "/home/brandon/toolchain/lua/ldo.c",
"line": 511,
"message": "Variable(s) 'ci' modified and accessed in unsequenced function arguments",
"rule_id": "EXP30-C",
"severity": "High",
"suggestion": "Separate the modification from the function call"
},
{
"column": 13,
"file": "/home/brandon/toolchain/lua/ldo.c",
"line": 511,
"message": "Assignment in if statement condition: 'ci = ci->previous'",
"rule_id": "EXP45-C",
"severity": "Medium",
"suggestion": "Use == for comparison, or move assignment outside if condition"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/ldo.c",
"line": 525,
"message": "Function 'tryfuncTM' participates in indirect recursion: tryfuncTM -> luaG_callerror -> typeerror -> luaT_objtypename -> luaS_new -> luaS_newlstr -> internshrstr -> growstrtab -> luaC_fullgc -> fullgen -> entergen -> atomic2gen -> finishgencycle -> luaD_checkminstack -> luaD_growstack -> luaG_runerror -> luaG_errormsg -> luaD_callnoyield -> ccall -> luaD_precall -> tryfuncTM",
"rule_id": "MSC04-C",
"severity": "Medium",
"suggestion": "Refactor to eliminate the recursion cycle"
},
{
"column": 8,
"file": "/home/brandon/toolchain/lua/ldo.c",
"line": 535,
"message": "Variable 'status' used with both bitwise and arithmetic operations (reduces code readability)",
"rule_id": "INT14-C",
"severity": "Medium",
"suggestion": "Use separate variables for bitwise and arithmetic operations, or refactor to use only arithmetic operators"
},
{
"column": 10,
"file": "/home/brandon/toolchain/lua/ldo.c",
"line": 537,
"message": "Variable 'CIST_CCMT' used with both bitwise and arithmetic operations (reduces code readability)",
"rule_id": "INT14-C",
"severity": "Medium",
"suggestion": "Use separate variables for bitwise and arithmetic operations, or refactor to use only arithmetic operators"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/ldo.c",
"line": 542,
"message": "Function 'genmoveresults' does not validate pointer parameter 'L' before use",
"rule_id": "API00-C",
"severity": "Medium",
"suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/ldo.c",
"line": 542,
"message": "Function 'genmoveresults' does not validate integer parameter 'wanted' for overflow before arithmetic operations",
"rule_id": "API00-C",
"severity": "Medium",
"suggestion": "Add overflow validation for 'wanted' before arithmetic, e.g., check against INT_MAX/INT_MIN or use __builtin_*_overflow()"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/ldo.c",
"line": 542,
"message": "Function 'genmoveresults' should be declared static if it doesn't need external linkage",
"rule_id": "DCL15-C",
"severity": "Low",
"suggestion": "Add 'static' storage-class specifier: static l_sinline genmoveresults"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/ldo.c",
"line": 542,
"message": "Function 'genmoveresults' is only used within this file. It should be declared static to minimize scope.",
"rule_id": "DCL19-C",
"severity": "Low",
"suggestion": "Add 'static' storage class to function 'genmoveresults'"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/ldo.c",
"line": 563,
"message": "Function 'moveresults' does not validate pointer parameter 'L' before use",
"rule_id": "API00-C",
"severity": "Medium",
"suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/ldo.c",
"line": 563,
"message": "Function 'moveresults' should be declared static if it doesn't need external linkage",
"rule_id": "DCL15-C",
"severity": "Low",
"suggestion": "Add 'static' storage-class specifier: static l_sinline moveresults"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/ldo.c",
"line": 563,
"message": "Function 'moveresults' is only used within this file. It should be declared static to minimize scope.",
"rule_id": "DCL19-C",
"severity": "Low",
"suggestion": "Add 'static' storage class to function 'moveresults'"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/ldo.c",
"line": 563,
"message": "Function 'moveresults' participates in indirect recursion: moveresults -> luaF_close -> prepcallclosemth -> callclosemethod -> luaD_call -> ccall -> luaD_precall -> precallC -> luaD_poscall -> moveresults",
"rule_id": "MSC04-C",
"severity": "Medium",
"suggestion": "Refactor to eliminate the recursion cycle"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/ldo.c",
"line": 607,
"message": "Function 'luaD_poscall' does not validate pointer parameter 'L' before use",
"rule_id": "API00-C",
"severity": "Medium",
"suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/ldo.c",
"line": 607,
"message": "Function 'luaD_poscall' does not validate pointer parameter 'ci' before use",
"rule_id": "API00-C",
"severity": "Medium",
"suggestion": "Add validation check for 'ci' at the start of the function, e.g., 'if (!ci) { return error_code; }'"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/ldo.c",
"line": 607,
"message": "Function 'luaD_poscall' participates in indirect recursion: luaD_poscall -> moveresults -> luaF_close -> prepcallclosemth -> callclosemethod -> luaD_call -> ccall -> luaD_precall -> precallC -> luaD_poscall",
"rule_id": "MSC04-C",
"severity": "Medium",
"suggestion": "Refactor to eliminate the recursion cycle"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/ldo.c",
"line": 621,
"message": "Function-like macro 'next_ci' evaluates parameter(s) multiple times; prefer inline or static functions for type safety",
"rule_id": "PRE00-C",
"severity": "Low",
"suggestion": null
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/ldo.c",
"line": 621,
"message": "Macro parameter 'L' is not parenthesized in replacement text. This can cause operator precedence issues.",
"rule_id": "PRE01-C",
"severity": "Medium",
"suggestion": "Wrap parameter 'L' in parentheses: (L) instead of L"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/ldo.c",
"line": 621,
"message": "Macro evaluates parameter 'L' multiple times; use inline function instead",
"rule_id": "PRE12-C",
"severity": "Medium",
"suggestion": "Replace macro with inline function to avoid multiple evaluation"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/ldo.c",
"line": 630,
"message": "Function 'prepCallInfo' does not validate pointer parameter 'L' before use",
"rule_id": "API00-C",
"severity": "Medium",
"suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/ldo.c",
"line": 630,
"message": "Function 'prepCallInfo' should be declared static if it doesn't need external linkage",
"rule_id": "DCL15-C",
"severity": "Low",
"suggestion": "Add 'static' storage-class specifier: static l_sinline prepCallInfo"
},
{
"column": 3,
"file": "/home/brandon/toolchain/lua/ldo.c",
"line": 637,
"message": "Function returns pointer to local variable 'ci' with automatic storage duration",
"rule_id": "DCL30-C",
"severity": "High",
"suggestion": "Use static storage, allocated memory, or pass output buffer as parameter"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/ldo.c",
"line": 644,
"message": "Function 'precallC' does not validate pointer parameter 'L' before use",
"rule_id": "API00-C",
"severity": "Medium",
"suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/ldo.c",
"line": 644,
"message": "Function 'precallC' should be declared static if it doesn't need external linkage",
"rule_id": "DCL15-C",
"severity": "Low",
"suggestion": "Add 'static' storage-class specifier: static l_sinline precallC"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/ldo.c",
"line": 644,
"message": "Function 'precallC' is only used within this file. It should be declared static to minimize scope.",
"rule_id": "DCL19-C",
"severity": "Low",
"suggestion": "Add 'static' storage class to function 'precallC'"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/ldo.c",
"line": 644,
"message": "Function 'precallC' participates in indirect recursion: precallC -> luaD_poscall -> moveresults -> luaF_close -> prepcallclosemth -> callclosemethod -> luaD_call -> ccall -> luaD_precall -> precallC",
"rule_id": "MSC04-C",
"severity": "Medium",
"suggestion": "Refactor to eliminate the recursion cycle"
},
{
"column": 32,
"file": "/home/brandon/toolchain/lua/ldo.c",
"line": 650,
"message": "Variable 'L' used with both bitwise and arithmetic operations (reduces code readability)",
"rule_id": "INT14-C",
"severity": "Medium",
"suggestion": "Use separate variables for bitwise and arithmetic operations, or refactor to use only arithmetic operators"
},
{
"column": 14,
"file": "/home/brandon/toolchain/lua/ldo.c",
"line": 651,
"message": "Potential null pointer dereference in member access of variable 'ci'",
"rule_id": "EXP34-C",
"severity": "High",
"suggestion": "Check if 'ci' is not NULL before member access"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/ldo.c",
"line": 671,
"message": "Function 'luaD_pretailcall' does not validate pointer parameter 'L' before use",
"rule_id": "API00-C",
"severity": "Medium",
"suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/ldo.c",
"line": 671,
"message": "Function 'luaD_pretailcall' does not validate pointer parameter 'ci' before use",
"rule_id": "API00-C",
"severity": "Medium",
"suggestion": "Add validation check for 'ci' at the start of the function, e.g., 'if (!ci) { return error_code; }'"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/ldo.c",
"line": 671,
"message": "Function 'luaD_pretailcall' does not validate integer parameter 'narg1' for overflow before arithmetic operations",
"rule_id": "API00-C",
"severity": "Medium",
"suggestion": "Add overflow validation for 'narg1' before arithmetic, e.g., check against INT_MAX/INT_MIN or use __builtin_*_overflow()"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/ldo.c",
"line": 671,
"message": "Function 'luaD_pretailcall' does not validate integer parameter 'delta' for overflow before arithmetic operations",
"rule_id": "API00-C",
"severity": "Medium",
"suggestion": "Add overflow validation for 'delta' before arithmetic, e.g., check against INT_MAX/INT_MIN or use __builtin_*_overflow()"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/ldo.c",
"line": 671,
"message": "Function 'luaD_pretailcall' participates in indirect recursion: luaD_pretailcall -> precallC -> luaD_poscall -> moveresults -> luaF_close -> prepcallclosemth -> callclosemethod -> luaD_call -> ccall -> luaV_execute -> luaD_pretailcall",
"rule_id": "MSC04-C",
"severity": "Medium",
"suggestion": "Refactor to eliminate the recursion cycle"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/ldo.c",
"line": 671,
"message": "Non-void function may reach end without returning a value. Ensure all execution paths have explicit return statements.",
"rule_id": "MSC37-C",
"severity": "Medium",
"suggestion": "Add return statements to ensure all execution paths return a value"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/ldo.c",
"line": 717,
"message": "Function 'luaD_precall' does not validate pointer parameter 'L' before use",
"rule_id": "API00-C",
"severity": "Medium",
"suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/ldo.c",
"line": 717,
"message": "Function 'luaD_precall' does not validate integer parameter 'nresults' for overflow before arithmetic operations",
"rule_id": "API00-C",
"severity": "Medium",
"suggestion": "Add overflow validation for 'nresults' before arithmetic, e.g., check against INT_MAX/INT_MIN or use __builtin_*_overflow()"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/ldo.c",
"line": 717,
"message": "Function 'luaD_precall' participates in indirect recursion: luaD_precall -> precallC -> luaD_poscall -> moveresults -> luaF_close -> prepcallclosemth -> callclosemethod -> luaD_call -> ccall -> luaD_precall",
"rule_id": "MSC04-C",
"severity": "Medium",
"suggestion": "Refactor to eliminate the recursion cycle"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/ldo.c",
"line": 717,
"message": "Non-void function may reach end without returning a value. Ensure all execution paths have explicit return statements.",
"rule_id": "MSC37-C",
"severity": "Medium",
"suggestion": "Add return statements to ensure all execution paths return a value"
},
{
"column": 7,
"file": "/home/brandon/toolchain/lua/ldo.c",
"line": 736,
"message": "Potential null pointer dereference in member access of variable 'ci'",
"rule_id": "EXP34-C",
"severity": "High",
"suggestion": "Check if 'ci' is not NULL before member access"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/ldo.c",
"line": 759,
"message": "Function 'ccall' does not validate pointer parameter 'L' before use",
"rule_id": "API00-C",
"severity": "Medium",
"suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/ldo.c",
"line": 759,
"message": "Function 'ccall' should be declared static if it doesn't need external linkage",
"rule_id": "DCL15-C",
"severity": "Low",
"suggestion": "Add 'static' storage-class specifier: static l_sinline ccall"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/ldo.c",
"line": 759,
"message": "Function 'ccall' is only used within this file. It should be declared static to minimize scope.",
"rule_id": "DCL19-C",
"severity": "Low",
"suggestion": "Add 'static' storage class to function 'ccall'"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/ldo.c",
"line": 759,
"message": "Function 'ccall' participates in indirect recursion: ccall -> luaE_checkcstack -> luaG_runerror -> luaG_errormsg -> luaD_callnoyield -> ccall",
"rule_id": "MSC04-C",
"severity": "Medium",
"suggestion": "Refactor to eliminate the recursion cycle"
},
{
"column": 5,
"file": "/home/brandon/toolchain/lua/ldo.c",
"line": 767,
"message": "Potential null pointer dereference in member access of variable 'ci'",
"rule_id": "EXP34-C",
"severity": "High",
"suggestion": "Check if 'ci' is not NULL before member access"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/ldo.c",
"line": 777,
"message": "Function 'luaD_call' does not validate pointer parameter 'L' before use",
"rule_id": "API00-C",
"severity": "Medium",
"suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/ldo.c",
"line": 777,
"message": "Function 'luaD_call' participates in indirect recursion: luaD_call -> ccall -> luaD_precall -> precallC -> luaD_poscall -> moveresults -> luaF_close -> prepcallclosemth -> callclosemethod -> luaD_call",
"rule_id": "MSC04-C",
"severity": "Medium",
"suggestion": "Refactor to eliminate the recursion cycle"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/ldo.c",
"line": 785,
"message": "Function 'luaD_callnoyield' does not validate pointer parameter 'L' before use",
"rule_id": "API00-C",
"severity": "Medium",
"suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/ldo.c",
"line": 785,
"message": "Function 'luaD_callnoyield' participates in indirect recursion: luaD_callnoyield -> ccall -> luaD_precall -> precallC -> luaD_poscall -> moveresults -> luaF_close -> prepcallclosemth -> callclosemethod -> luaD_callnoyield",
"rule_id": "MSC04-C",
"severity": "Medium",
"suggestion": "Refactor to eliminate the recursion cycle"
},
{
"column": 39,
"file": "/home/brandon/toolchain/lua/ldo.c",
"line": 886,
"message": "Pointer parameter 'L' is not modified and should be declared const",
"rule_id": "DCL13-C",
"severity": "Low",
"suggestion": "Declare parameter as 'const <type> *L'"
},
{
"column": 7,
"file": "/home/brandon/toolchain/lua/ldo.c",
"line": 890,
"message": "Function returns pointer to local variable 'ci' with automatic storage duration",
"rule_id": "DCL30-C",
"severity": "High",
"suggestion": "Use static storage, allocated memory, or pass output buffer as parameter"
},
{
"column": 40,
"file": "/home/brandon/toolchain/lua/ldo.c",
"line": 918,
"message": "Pointer parameter 'ud' is not modified and should be declared const",
"rule_id": "DCL13-C",
"severity": "Low",
"suggestion": "Declare parameter as 'const <type> *ud'"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/ldo.c",
"line": 968,
"message": "Function 'lua_resume' does not validate pointer parameter 'from' before use",
"rule_id": "API00-C",
"severity": "Medium",
"suggestion": "Add validation check for 'from' at the start of the function, e.g., 'if (!from) { return error_code; }'"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/ldo.c",
"line": 968,
"message": "Function 'lua_resume' does not validate pointer parameter 'nresults' before use",
"rule_id": "API00-C",
"severity": "Medium",
"suggestion": "Add validation check for 'nresults' at the start of the function, e.g., 'if (!nresults) { return error_code; }'"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/ldo.c",
"line": 968,
"message": "Function 'lua_resume' does not validate integer parameter 'nargs' for overflow before arithmetic operations",
"rule_id": "API00-C",
"severity": "Medium",
"suggestion": "Add overflow validation for 'nargs' before arithmetic, e.g., check against INT_MAX/INT_MIN or use __builtin_*_overflow()"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/ldo.c",
"line": 968,
"message": "Function 'lua_resume' should be declared static if it doesn't need external linkage",
"rule_id": "DCL15-C",
"severity": "Low",
"suggestion": "Add 'static' storage-class specifier: static LUA_API lua_resume"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/ldo.c",
"line": 1003,
"message": "Function 'lua_isyieldable' does not validate pointer parameter 'L' before use",
"rule_id": "API00-C",
"severity": "Medium",
"suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/ldo.c",
"line": 1003,
"message": "Function 'lua_isyieldable' should be declared static if it doesn't need external linkage",
"rule_id": "DCL15-C",
"severity": "Low",
"suggestion": "Add 'static' storage-class specifier: static LUA_API lua_isyieldable"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/ldo.c",
"line": 1008,
"message": "Function 'lua_yieldk' does not validate pointer parameter 'L' before use",
"rule_id": "API00-C",
"severity": "Medium",
"suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/ldo.c",
"line": 1008,
"message": "Function 'lua_yieldk' should be declared static if it doesn't need external linkage",
"rule_id": "DCL15-C",
"severity": "Low",
"suggestion": "Add 'static' storage-class specifier: static LUA_API lua_yieldk"
},
{
"column": 43,
"file": "/home/brandon/toolchain/lua/ldo.c",
"line": 1051,
"message": "Pointer parameter 'ud' is not modified and should be declared const",
"rule_id": "DCL13-C",
"severity": "Low",
"suggestion": "Declare parameter as 'const <type> *ud'"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/ldo.c",
"line": 1061,
"message": "Function 'luaD_closeprotected' does not validate pointer parameter 'L' before use",
"rule_id": "API00-C",
"severity": "Medium",
"suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/ldo.c",
"line": 1061,
"message": "Non-void function may reach end without returning a value. Ensure all execution paths have explicit return statements.",
"rule_id": "MSC37-C",
"severity": "Medium",
"suggestion": "Add return statements to ensure all execution paths return a value"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/ldo.c",
"line": 1083,
"message": "Function 'luaD_pcall' does not validate pointer parameter 'L' before use",
"rule_id": "API00-C",
"severity": "Medium",
"suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/ldo.c",
"line": 1083,
"message": "Function 'luaD_pcall' does not validate pointer parameter 'u' before use",
"rule_id": "API00-C",
"severity": "Medium",
"suggestion": "Add validation check for 'u' at the start of the function, e.g., 'if (!u) { return error_code; }'"
},
{
"column": 42,
"file": "/home/brandon/toolchain/lua/ldo.c",
"line": 1129,
"message": "Pointer parameter 'ud' is not modified and should be declared const",
"rule_id": "DCL13-C",
"severity": "Low",
"suggestion": "Declare parameter as 'const <type> *ud'"
},
{
"column": 12,
"file": "/home/brandon/toolchain/lua/ldo.c",
"line": 1137,
"message": "Memory allocated with 'luaH_new' for variable 'anchor' is not freed",
"rule_id": "MEM31-C",
"severity": "High",
"suggestion": "Add 'free(anchor)' before the variable goes out of scope"
},
{
"column": 14,
"file": "/home/brandon/toolchain/lua/ldo.c",
"line": 1154,
"message": "Potential null pointer dereference in member access of variable 'cl'",
"rule_id": "EXP34-C",
"severity": "High",
"suggestion": "Check if 'cl' is not NULL before member access"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/ldo.c",
"line": 1164,
"message": "Function 'luaD_anchorobj' does not validate pointer parameter 'L' before use",
"rule_id": "API00-C",
"severity": "Medium",
"suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/ldo.c",
"line": 1164,
"message": "Function 'luaD_anchorobj' does not validate pointer parameter 'anchor' before use",
"rule_id": "API00-C",
"severity": "Medium",
"suggestion": "Add validation check for 'anchor' at the start of the function, e.g., 'if (!anchor) { return error_code; }'"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/ldo.c",
"line": 1164,
"message": "Function 'luaD_anchorobj' does not validate pointer parameter 'obj' before use",
"rule_id": "API00-C",
"severity": "Medium",
"suggestion": "Add validation check for 'obj' at the start of the function, e.g., 'if (!obj) { return error_code; }'"
},
{
"column": 3,
"file": "/home/brandon/toolchain/lua/ldo.c",
"line": 1166,
"message": "Multiple function calls with potential side effects in unsequenced arguments",
"rule_id": "EXP30-C",
"severity": "High",
"suggestion": "Evaluate function calls in separate statements to guarantee ordering"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/ldo.c",
"line": 1173,
"message": "Function 'luaD_protectedparser' does not validate pointer parameter 'L' before use",
"rule_id": "API00-C",
"severity": "Medium",
"suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/ldo.c",
"line": 1173,
"message": "Function 'luaD_protectedparser' does not validate pointer parameter 'z' before use",
"rule_id": "API00-C",
"severity": "Medium",
"suggestion": "Add validation check for 'z' at the start of the function, e.g., 'if (!z) { return error_code; }'"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/ldo.c",
"line": 1173,
"message": "Function 'luaD_protectedparser' does not validate pointer parameter 'name' before use",
"rule_id": "API00-C",
"severity": "Medium",
"suggestion": "Add validation check for 'name' at the start of the function, e.g., 'if (!name) { return error_code; }'"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/ldo.c",
"line": 1173,
"message": "Function 'luaD_protectedparser' does not validate pointer parameter 'mode' before use",
"rule_id": "API00-C",
"severity": "Medium",
"suggestion": "Add validation check for 'mode' at the start of the function, e.g., 'if (!mode) { return error_code; }'"
},
{
"column": 49,
"file": "/home/brandon/toolchain/lua/ldo.c",
"line": 1173,
"message": "Pointer parameter 'z' is not modified and should be declared const",
"rule_id": "DCL13-C",
"severity": "Low",
"suggestion": "Declare parameter as 'const <type> *z'"
}
]
}