sqc 0.4.84

Software Code Quality - CERT C compliance checker
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
{
"lparser.c": [
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lparser.c",
"line": 38,
"message": "Function-like macro 'hasmultret' 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/lparser.c",
"line": 38,
"message": "Macro evaluates parameter 'k' 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/lparser.c",
"line": 68,
"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/lparser.c",
"line": 74,
"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": 38,
"file": "/home/brandon/toolchain/lua/lparser.c",
"line": 74,
"message": "Pointer parameter 'fs' is not modified and should be declared const",
"rule_id": "DCL13-C",
"severity": "Low",
"suggestion": "Declare parameter as 'const <type> *fs'"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lparser.c",
"line": 122,
"message": "Multistatement macro 'check_condition' 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": 28,
"file": "/home/brandon/toolchain/lua/lparser.c",
"line": 135,
"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": 3,
"file": "/home/brandon/toolchain/lua/lparser.c",
"line": 148,
"message": "Function returns pointer to local variable 'ts' with automatic storage duration",
"rule_id": "DCL30-C",
"severity": "High",
"suggestion": "Use static storage, allocated memory, or pass output buffer as parameter"
},
{
"column": 45,
"file": "/home/brandon/toolchain/lua/lparser.c",
"line": 159,
"message": "Pointer parameter 's' is not modified and should be declared const",
"rule_id": "DCL13-C",
"severity": "Low",
"suggestion": "Declare parameter as 'const <type> *s'"
},
{
"column": 41,
"file": "/home/brandon/toolchain/lua/lparser.c",
"line": 175,
"message": "Pointer parameter 'ls' is not modified and should be declared const",
"rule_id": "DCL13-C",
"severity": "Low",
"suggestion": "Declare parameter as 'const <type> *ls'"
},
{
"column": 34,
"file": "/home/brandon/toolchain/lua/lparser.c",
"line": 194,
"message": "Pointer parameter 'ls' is not modified and should be declared const",
"rule_id": "DCL13-C",
"severity": "Low",
"suggestion": "Declare parameter as 'const <type> *ls'"
},
{
"column": 47,
"file": "/home/brandon/toolchain/lua/lparser.c",
"line": 194,
"message": "Pointer parameter 'name' is not modified and should be declared const",
"rule_id": "DCL13-C",
"severity": "Low",
"suggestion": "Declare parameter as 'const <type> *name'"
},
{
"column": 3,
"file": "/home/brandon/toolchain/lua/lparser.c",
"line": 199,
"message": "Function 'luaM_growvector' called with overlapping memory regions. If parameters are restrict-qualified, this causes undefined behavior.",
"rule_id": "EXP43-C",
"severity": "High",
"suggestion": "Ensure memory regions do not overlap when using restrict pointers"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lparser.c",
"line": 215,
"message": "Function-like macro 'new_localvarliteral' 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/lparser.c",
"line": 215,
"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: (new_localvar(ls,  \\\n      luaX_newstring(ls, \"\" v, (sizeof(v)/sizeof(char)) - 1));)"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lparser.c",
"line": 215,
"message": "Macro 'new_localvarliteral' definition ends with a semicolon. This can cause unexpected behavior when the macro is used.",
"rule_id": "PRE11-C",
"severity": "Medium",
"suggestion": "Remove the trailing semicolon from the macro definition. The semicolon should be added by the macro user, not in the definition."
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lparser.c",
"line": 215,
"message": "Macro evaluates parameter 'ls' multiple times; use inline function instead",
"rule_id": "PRE12-C",
"severity": "Medium",
"suggestion": "Replace macro with inline function to avoid multiple evaluation"
},
{
"column": 44,
"file": "/home/brandon/toolchain/lua/lparser.c",
"line": 226,
"message": "Pointer parameter 'fs' is not modified and should be declared const",
"rule_id": "DCL13-C",
"severity": "Low",
"suggestion": "Declare parameter as 'const <type> *fs'"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lparser.c",
"line": 250,
"message": "Function 'luaY_nvarstack' does not validate pointer parameter 'fs' before use",
"rule_id": "API00-C",
"severity": "Medium",
"suggestion": "Add validation check for 'fs' at the start of the function, e.g., 'if (!fs) { return error_code; }'"
},
{
"column": 37,
"file": "/home/brandon/toolchain/lua/lparser.c",
"line": 360,
"message": "Pointer parameter 'fs' is not modified and should be declared const",
"rule_id": "DCL13-C",
"severity": "Low",
"suggestion": "Declare parameter as 'const <type> *fs'"
},
{
"column": 3,
"file": "/home/brandon/toolchain/lua/lparser.c",
"line": 373,
"message": "Function 'luaY_checklimit' called with overlapping memory regions. If parameters are restrict-qualified, this causes undefined behavior.",
"rule_id": "EXP43-C",
"severity": "High",
"suggestion": "Ensure memory regions do not overlap when using restrict pointers"
},
{
"column": 62,
"file": "/home/brandon/toolchain/lua/lparser.c",
"line": 382,
"message": "Pointer parameter 'v' is not modified and should be declared const",
"rule_id": "DCL13-C",
"severity": "Low",
"suggestion": "Declare parameter as 'const <type> *v'"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lparser.c",
"line": 476,
"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/lparser.c",
"line": 476,
"message": "Function 'singlevaraux' calls itself directly (direct recursion)",
"rule_id": "MSC04-C",
"severity": "Medium",
"suggestion": "Refactor to use iteration instead of recursion"
},
{
"column": 37,
"file": "/home/brandon/toolchain/lua/lparser.c",
"line": 547,
"message": "Pointer parameter 'ls' is not modified and should be declared const",
"rule_id": "DCL13-C",
"severity": "Low",
"suggestion": "Declare parameter as 'const <type> *ls'"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lparser.c",
"line": 570,
"message": "Macro parameter 'ls' is not parenthesized in replacement text. This can cause operator precedence issues.",
"rule_id": "PRE01-C",
"severity": "Medium",
"suggestion": "Wrap parameter 'ls' in parentheses: (ls) instead of ls"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lparser.c",
"line": 573,
"message": "Function-like macro 'leavelevel' 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/lparser.c",
"line": 580,
"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": 56,
"file": "/home/brandon/toolchain/lua/lparser.c",
"line": 580,
"message": "Pointer parameter 'gt' is not modified and should be declared const",
"rule_id": "DCL13-C",
"severity": "Low",
"suggestion": "Declare parameter as 'const <type> *gt'"
},
{
"column": 55,
"file": "/home/brandon/toolchain/lua/lparser.c",
"line": 597,
"message": "Pointer parameter 'label' is not modified and should be declared const",
"rule_id": "DCL13-C",
"severity": "Low",
"suggestion": "Declare parameter as 'const <type> *label'"
},
{
"column": 20,
"file": "/home/brandon/toolchain/lua/lparser.c",
"line": 601,
"message": "Array subscript uses function parameter 'g' without bounds checking. Caller could pass invalid index.",
"rule_id": "ARR00-C",
"severity": "Medium",
"suggestion": "Add bounds checking for 'g' before using it as an array index"
},
{
"column": 27,
"file": "/home/brandon/toolchain/lua/lparser.c",
"line": 611,
"message": "Memory allocated with 'CREATE_ABCk' for variable 'fs->f->code[gt->pc]' is not freed",
"rule_id": "MEM31-C",
"severity": "High",
"suggestion": "Add 'free(fs->f->code[gt->pc])' before the variable goes out of scope"
},
{
"column": 39,
"file": "/home/brandon/toolchain/lua/lparser.c",
"line": 626,
"message": "Pointer parameter 'ls' is not modified and should be declared const",
"rule_id": "DCL13-C",
"severity": "Low",
"suggestion": "Declare parameter as 'const <type> *ls'"
},
{
"column": 3,
"file": "/home/brandon/toolchain/lua/lparser.c",
"line": 628,
"message": "Loop uses uninitialized variable 'ilb' as bound for array access. This has indeterminate value and can cause out-of-bounds access.",
"rule_id": "ARR00-C",
"severity": "Medium",
"suggestion": "Initialize 'ilb' to a valid value before using it in the loop"
},
{
"column": 36,
"file": "/home/brandon/toolchain/lua/lparser.c",
"line": 640,
"message": "Pointer parameter 'ls' is not modified and should be declared const",
"rule_id": "DCL13-C",
"severity": "Low",
"suggestion": "Declare parameter as 'const <type> *ls'"
},
{
"column": 63,
"file": "/home/brandon/toolchain/lua/lparser.c",
"line": 640,
"message": "Pointer parameter 'name' is not modified and should be declared const",
"rule_id": "DCL13-C",
"severity": "Low",
"suggestion": "Declare parameter as 'const <type> *name'"
},
{
"column": 49,
"file": "/home/brandon/toolchain/lua/lparser.c",
"line": 696,
"message": "Pointer parameter 'bl' is not modified and should be declared const",
"rule_id": "DCL13-C",
"severity": "Low",
"suggestion": "Declare parameter as 'const <type> *bl'"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lparser.c",
"line": 737,
"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": 51,
"file": "/home/brandon/toolchain/lua/lparser.c",
"line": 737,
"message": "Pointer parameter 'gt' is not modified and should be declared const",
"rule_id": "DCL13-C",
"severity": "Low",
"suggestion": "Declare parameter as 'const <type> *gt'"
},
{
"column": 38,
"file": "/home/brandon/toolchain/lua/lparser.c",
"line": 768,
"message": "Pointer parameter 'ls' is not modified and should be declared const",
"rule_id": "DCL13-C",
"severity": "Low",
"suggestion": "Declare parameter as 'const <type> *ls'"
},
{
"column": 3,
"file": "/home/brandon/toolchain/lua/lparser.c",
"line": 781,
"message": "Function returns pointer to local variable 'clp' with automatic storage duration",
"rule_id": "DCL30-C",
"severity": "High",
"suggestion": "Use static storage, allocated memory, or pass output buffer as parameter"
},
{
"column": 35,
"file": "/home/brandon/toolchain/lua/lparser.c",
"line": 792,
"message": "Pointer parameter 'ls' is not modified and should be declared const",
"rule_id": "DCL13-C",
"severity": "Low",
"suggestion": "Declare parameter as 'const <type> *ls'"
},
{
"column": 16,
"file": "/home/brandon/toolchain/lua/lparser.c",
"line": 823,
"message": "Memory allocated with 'luaH_new' for variable 'fs->kcache' is not freed",
"rule_id": "MEM31-C",
"severity": "High",
"suggestion": "Add 'free(fs->kcache)' before the variable goes out of scope"
},
{
"column": 35,
"file": "/home/brandon/toolchain/lua/lparser.c",
"line": 866,
"message": "Pointer parameter 'ls' is not modified and should be declared const",
"rule_id": "DCL13-C",
"severity": "Low",
"suggestion": "Declare parameter as 'const <type> *ls'"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lparser.c",
"line": 877,
"message": "Function 'statlist' participates in indirect recursion: statlist -> statement -> localstat -> explist -> expr -> subexpr -> simpleexp -> body -> statlist",
"rule_id": "MSC04-C",
"severity": "Medium",
"suggestion": "Refactor to eliminate the recursion cycle"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lparser.c",
"line": 900,
"message": "Function 'yindex' participates in indirect recursion: yindex -> expr -> subexpr -> simpleexp -> suffixedexp -> funcargs -> constructor -> field -> recfield -> yindex",
"rule_id": "MSC04-C",
"severity": "Medium",
"suggestion": "Refactor to eliminate the recursion cycle"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lparser.c",
"line": 938,
"message": "Function 'recfield' participates in indirect recursion: recfield -> yindex -> expr -> subexpr -> simpleexp -> suffixedexp -> funcargs -> constructor -> field -> recfield",
"rule_id": "MSC04-C",
"severity": "Medium",
"suggestion": "Refactor to eliminate the recursion cycle"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lparser.c",
"line": 985,
"message": "Function 'listfield' participates in indirect recursion: listfield -> expr -> subexpr -> simpleexp -> suffixedexp -> funcargs -> constructor -> field -> listfield",
"rule_id": "MSC04-C",
"severity": "Medium",
"suggestion": "Refactor to eliminate the recursion cycle"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lparser.c",
"line": 992,
"message": "Function 'field' participates in indirect recursion: field -> recfield -> expr -> subexpr -> simpleexp -> suffixedexp -> funcargs -> constructor -> field",
"rule_id": "MSC04-C",
"severity": "Medium",
"suggestion": "Refactor to eliminate the recursion cycle"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lparser.c",
"line": 1019,
"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": 34,
"file": "/home/brandon/toolchain/lua/lparser.c",
"line": 1019,
"message": "Pointer parameter 'fs' is not modified and should be declared const",
"rule_id": "DCL13-C",
"severity": "Low",
"suggestion": "Declare parameter as 'const <type> *fs'"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lparser.c",
"line": 1030,
"message": "Function 'constructor' participates in indirect recursion: constructor -> field -> listfield -> expr -> subexpr -> simpleexp -> suffixedexp -> funcargs -> constructor",
"rule_id": "MSC04-C",
"severity": "Medium",
"suggestion": "Refactor to eliminate the recursion cycle"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lparser.c",
"line": 1105,
"message": "Function 'body' participates in indirect recursion: body -> statlist -> statement -> localstat -> explist -> expr -> subexpr -> simpleexp -> body",
"rule_id": "MSC04-C",
"severity": "Medium",
"suggestion": "Refactor to eliminate the recursion cycle"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lparser.c",
"line": 1127,
"message": "Function 'explist' participates in indirect recursion: explist -> expr -> subexpr -> simpleexp -> suffixedexp -> funcargs -> explist",
"rule_id": "MSC04-C",
"severity": "Medium",
"suggestion": "Refactor to eliminate the recursion cycle"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lparser.c",
"line": 1140,
"message": "Function 'funcargs' participates in indirect recursion: funcargs -> explist -> expr -> subexpr -> simpleexp -> suffixedexp -> funcargs",
"rule_id": "MSC04-C",
"severity": "Medium",
"suggestion": "Refactor to eliminate the recursion cycle"
},
{
"column": 24,
"file": "/home/brandon/toolchain/lua/lparser.c",
"line": 1152,
"message": "Variable 'args' is used uninitialized",
"rule_id": "EXP33-C",
"severity": "High",
"suggestion": "Initialize 'args' before use, e.g., at its declaration"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lparser.c",
"line": 1198,
"message": "Function 'primaryexp' participates in indirect recursion: primaryexp -> expr -> subexpr -> simpleexp -> suffixedexp -> primaryexp",
"rule_id": "MSC04-C",
"severity": "Medium",
"suggestion": "Refactor to eliminate the recursion cycle"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lparser.c",
"line": 1220,
"message": "Function 'suffixedexp' participates in indirect recursion: suffixedexp -> yindex -> expr -> subexpr -> simpleexp -> suffixedexp",
"rule_id": "MSC04-C",
"severity": "Medium",
"suggestion": "Refactor to eliminate the recursion cycle"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lparser.c",
"line": 1257,
"message": "Function 'simpleexp' participates in indirect recursion: simpleexp -> constructor -> field -> listfield -> expr -> subexpr -> simpleexp",
"rule_id": "MSC04-C",
"severity": "Medium",
"suggestion": "Refactor to eliminate the recursion cycle"
},
{
"column": 3,
"file": "/home/brandon/toolchain/lua/lparser.c",
"line": 1357,
"message": "Array declaration 'priority[]' has implicit bounds; specify explicit size",
"rule_id": "ARR02-C",
"severity": "Medium",
"suggestion": "Explicitly specify array bounds even when using an initializer"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lparser.c",
"line": 1377,
"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/lparser.c",
"line": 1377,
"message": "Function 'subexpr' 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/lparser.c",
"line": 1407,
"message": "Function 'expr' participates in indirect recursion: expr -> subexpr -> simpleexp -> suffixedexp -> funcargs -> constructor -> field -> listfield -> expr",
"rule_id": "MSC04-C",
"severity": "Medium",
"suggestion": "Refactor to eliminate the recursion cycle"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lparser.c",
"line": 1422,
"message": "Function 'block' participates in indirect recursion: block -> statlist -> statement -> ifstat -> block",
"rule_id": "MSC04-C",
"severity": "Medium",
"suggestion": "Refactor to eliminate the recursion cycle"
},
{
"column": 38,
"file": "/home/brandon/toolchain/lua/lparser.c",
"line": 1448,
"message": "Pointer parameter 'ls' is not modified and should be declared const",
"rule_id": "DCL13-C",
"severity": "Low",
"suggestion": "Declare parameter as 'const <type> *ls'"
},
{
"column": 74,
"file": "/home/brandon/toolchain/lua/lparser.c",
"line": 1448,
"message": "Pointer parameter 'v' is not modified and should be declared const",
"rule_id": "DCL13-C",
"severity": "Low",
"suggestion": "Declare parameter as 'const <type> *v'"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lparser.c",
"line": 1501,
"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/lparser.c",
"line": 1501,
"message": "Function 'restassign' 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/lparser.c",
"line": 1531,
"message": "Function 'cond' participates in indirect recursion: cond -> expr -> subexpr -> simpleexp -> body -> statlist -> statement -> repeatstat -> cond",
"rule_id": "MSC04-C",
"severity": "Medium",
"suggestion": "Refactor to eliminate the recursion cycle"
},
{
"column": 3,
"file": "/home/brandon/toolchain/lua/lparser.c",
"line": 1558,
"message": "Potential null pointer dereference in member access of variable 'bl'",
"rule_id": "EXP34-C",
"severity": "High",
"suggestion": "Check if 'bl' is not NULL before member access"
},
{
"column": 37,
"file": "/home/brandon/toolchain/lua/lparser.c",
"line": 1572,
"message": "Potential null pointer dereference in member access of variable 'lb'",
"rule_id": "EXP34-C",
"severity": "High",
"suggestion": "Check if 'lb' is not NULL before member access"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lparser.c",
"line": 1576,
"message": "Function 'labelstat' participates in indirect recursion: labelstat -> statement -> labelstat",
"rule_id": "MSC04-C",
"severity": "Medium",
"suggestion": "Refactor to eliminate the recursion cycle"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lparser.c",
"line": 1586,
"message": "Function 'whilestat' participates in indirect recursion: whilestat -> block -> statlist -> statement -> whilestat",
"rule_id": "MSC04-C",
"severity": "Medium",
"suggestion": "Refactor to eliminate the recursion cycle"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lparser.c",
"line": 1605,
"message": "Function 'repeatstat' participates in indirect recursion: repeatstat -> cond -> expr -> subexpr -> simpleexp -> body -> statlist -> statement -> repeatstat",
"rule_id": "MSC04-C",
"severity": "Medium",
"suggestion": "Refactor to eliminate the recursion cycle"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lparser.c",
"line": 1635,
"message": "Function 'exp1' participates in indirect recursion: exp1 -> expr -> subexpr -> simpleexp -> body -> statlist -> statement -> forstat -> fornum -> exp1",
"rule_id": "MSC04-C",
"severity": "Medium",
"suggestion": "Refactor to eliminate the recursion cycle"
},
{
"column": 35,
"file": "/home/brandon/toolchain/lua/lparser.c",
"line": 1648,
"message": "Pointer parameter 'fs' is not modified and should be declared const",
"rule_id": "DCL13-C",
"severity": "Low",
"suggestion": "Declare parameter as 'const <type> *fs'"
},
{
"column": 23,
"file": "/home/brandon/toolchain/lua/lparser.c",
"line": 1649,
"message": "Array subscript uses function parameter 'pc' without bounds checking. Caller could pass invalid index.",
"rule_id": "ARR00-C",
"severity": "Medium",
"suggestion": "Add bounds checking for 'pc' before using it as an array index"
},
{
"column": 23,
"file": "/home/brandon/toolchain/lua/lparser.c",
"line": 1649,
"message": "Potentially unsafe array access with unvalidated function parameter index 'pc'",
"rule_id": "ARR30-C",
"severity": "High",
"suggestion": "Add bounds checking for function parameter before using as array index."
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lparser.c",
"line": 1662,
"message": "Function 'forbody' participates in indirect recursion: forbody -> block -> statlist -> statement -> forstat -> forlist -> forbody",
"rule_id": "MSC04-C",
"severity": "Medium",
"suggestion": "Refactor to eliminate the recursion cycle"
},
{
"column": 27,
"file": "/home/brandon/toolchain/lua/lparser.c",
"line": 1670,
"message": "Array subscript uses function parameter 'isgen' without bounds checking. Caller could pass invalid index.",
"rule_id": "ARR00-C",
"severity": "Medium",
"suggestion": "Add bounds checking for 'isgen' before using it as an array index"
},
{
"column": 29,
"file": "/home/brandon/toolchain/lua/lparser.c",
"line": 1682,
"message": "Array subscript uses function parameter 'isgen' without bounds checking. Caller could pass invalid index.",
"rule_id": "ARR00-C",
"severity": "Medium",
"suggestion": "Add bounds checking for 'isgen' before using it as an array index"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lparser.c",
"line": 1697,
"message": "Function 'fornum' participates in indirect recursion: fornum -> forbody -> block -> statlist -> statement -> forstat -> fornum",
"rule_id": "MSC04-C",
"severity": "Medium",
"suggestion": "Refactor to eliminate the recursion cycle"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lparser.c",
"line": 1719,
"message": "Function 'forlist' participates in indirect recursion: forlist -> forbody -> block -> statlist -> statement -> forstat -> forlist",
"rule_id": "MSC04-C",
"severity": "Medium",
"suggestion": "Refactor to eliminate the recursion cycle"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lparser.c",
"line": 1746,
"message": "Function 'forstat' participates in indirect recursion: forstat -> forlist -> explist -> expr -> subexpr -> simpleexp -> body -> statlist -> statement -> forstat",
"rule_id": "MSC04-C",
"severity": "Medium",
"suggestion": "Refactor to eliminate the recursion cycle"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lparser.c",
"line": 1764,
"message": "Function 'test_then_block' participates in indirect recursion: test_then_block -> cond -> expr -> subexpr -> simpleexp -> body -> statlist -> statement -> ifstat -> test_then_block",
"rule_id": "MSC04-C",
"severity": "Medium",
"suggestion": "Refactor to eliminate the recursion cycle"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lparser.c",
"line": 1779,
"message": "Function 'ifstat' participates in indirect recursion: ifstat -> test_then_block -> block -> statlist -> statement -> ifstat",
"rule_id": "MSC04-C",
"severity": "Medium",
"suggestion": "Refactor to eliminate the recursion cycle"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lparser.c",
"line": 1793,
"message": "Function 'localfunc' participates in indirect recursion: localfunc -> body -> statlist -> statement -> localfunc",
"rule_id": "MSC04-C",
"severity": "Medium",
"suggestion": "Refactor to eliminate the recursion cycle"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lparser.c",
"line": 1830,
"message": "Function 'localstat' participates in indirect recursion: localstat -> explist -> expr -> subexpr -> simpleexp -> body -> statlist -> statement -> localstat",
"rule_id": "MSC04-C",
"severity": "Medium",
"suggestion": "Refactor to eliminate the recursion cycle"
},
{
"column": 12,
"file": "/home/brandon/toolchain/lua/lparser.c",
"line": 1844,
"message": "Memory allocated with 'new_varkind' for variable 'vidx' is not freed",
"rule_id": "MEM31-C",
"severity": "High",
"suggestion": "Add 'free(vidx)' before the variable goes out of scope"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lparser.c",
"line": 1906,
"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/lparser.c",
"line": 1906,
"message": "Function 'initglobal' 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/lparser.c",
"line": 1927,
"message": "Function 'globalnames' participates in indirect recursion: globalnames -> initglobal -> explist -> expr -> subexpr -> simpleexp -> body -> statlist -> statement -> globalstatfunc -> globalstat -> globalnames",
"rule_id": "MSC04-C",
"severity": "Medium",
"suggestion": "Refactor to eliminate the recursion cycle"
},
{
"column": 15,
"file": "/home/brandon/toolchain/lua/lparser.c",
"line": 1934,
"message": "Memory allocated with 'new_varkind' for variable 'lastidx' is not freed",
"rule_id": "MEM31-C",
"severity": "High",
"suggestion": "Add 'free(lastidx)' before the variable goes out of scope"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lparser.c",
"line": 1943,
"message": "Function 'globalstat' participates in indirect recursion: globalstat -> globalnames -> initglobal -> explist -> expr -> subexpr -> simpleexp -> body -> statlist -> statement -> globalstatfunc -> globalstat",
"rule_id": "MSC04-C",
"severity": "Medium",
"suggestion": "Refactor to eliminate the recursion cycle"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lparser.c",
"line": 1959,
"message": "Function 'globalfunc' participates in indirect recursion: globalfunc -> body -> statlist -> statement -> globalstatfunc -> globalfunc",
"rule_id": "MSC04-C",
"severity": "Medium",
"suggestion": "Refactor to eliminate the recursion cycle"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lparser.c",
"line": 1974,
"message": "Function 'globalstatfunc' participates in indirect recursion: globalstatfunc -> globalfunc -> body -> statlist -> statement -> globalstatfunc",
"rule_id": "MSC04-C",
"severity": "Medium",
"suggestion": "Refactor to eliminate the recursion cycle"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lparser.c",
"line": 1998,
"message": "Function 'funcstat' participates in indirect recursion: funcstat -> body -> statlist -> statement -> funcstat",
"rule_id": "MSC04-C",
"severity": "Medium",
"suggestion": "Refactor to eliminate the recursion cycle"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lparser.c",
"line": 2011,
"message": "Function 'exprstat' participates in indirect recursion: exprstat -> restassign -> explist -> expr -> subexpr -> simpleexp -> body -> statlist -> statement -> exprstat",
"rule_id": "MSC04-C",
"severity": "Medium",
"suggestion": "Refactor to eliminate the recursion cycle"
},
{
"column": 20,
"file": "/home/brandon/toolchain/lua/lparser.c",
"line": 2015,
"message": "Variable 'v' is used uninitialized",
"rule_id": "EXP33-C",
"severity": "High",
"suggestion": "Initialize 'v' before use, e.g., at its declaration"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lparser.c",
"line": 2029,
"message": "Function 'retstat' participates in indirect recursion: retstat -> explist -> expr -> subexpr -> simpleexp -> body -> statlist -> statement -> retstat",
"rule_id": "MSC04-C",
"severity": "Medium",
"suggestion": "Refactor to eliminate the recursion cycle"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lparser.c",
"line": 2061,
"message": "Function 'statement' participates in indirect recursion: statement -> block -> statlist -> statement",
"rule_id": "MSC04-C",
"severity": "Medium",
"suggestion": "Refactor to eliminate the recursion cycle"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lparser.c",
"line": 2180,
"message": "Function 'luaY_parser' 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/lparser.c",
"line": 2180,
"message": "Function 'luaY_parser' 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/lparser.c",
"line": 2180,
"message": "Function 'luaY_parser' 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/lparser.c",
"line": 2180,
"message": "Function 'luaY_parser' 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/lparser.c",
"line": 2180,
"message": "Function 'luaY_parser' does not validate pointer parameter 'dyd' before use",
"rule_id": "API00-C",
"severity": "Medium",
"suggestion": "Add validation check for 'dyd' at the start of the function, e.g., 'if (!dyd) { return error_code; }'"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lparser.c",
"line": 2180,
"message": "Function 'luaY_parser' 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": 69,
"file": "/home/brandon/toolchain/lua/lparser.c",
"line": 2180,
"message": "Pointer parameter 'buff' is not modified and should be declared const",
"rule_id": "DCL13-C",
"severity": "Low",
"suggestion": "Declare parameter as 'const <type> *buff'"
},
{
"column": 17,
"file": "/home/brandon/toolchain/lua/lparser.c",
"line": 2188,
"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": 25,
"file": "/home/brandon/toolchain/lua/lparser.c",
"line": 2190,
"message": "Memory allocated with 'luaS_new' for variable 'funcstate.f->source' is not freed",
"rule_id": "MEM31-C",
"severity": "High",
"suggestion": "Add 'free(funcstate.f->source)' before the variable goes out of scope"
},
{
"column": 3,
"file": "/home/brandon/toolchain/lua/lparser.c",
"line": 2200,
"message": "Function returns pointer to local variable 'cl' with automatic storage duration",
"rule_id": "DCL30-C",
"severity": "High",
"suggestion": "Use static storage, allocated memory, or pass output buffer as parameter"
},
{
"column": 3,
"file": "/home/brandon/toolchain/lua/lparser.c",
"line": 2200,
"message": "Memory leak: 'funcstate.f->source' allocated with 'luaS_new' is not freed before return",
"rule_id": "MEM31-C",
"severity": "High",
"suggestion": "Free 'funcstate.f->source' before this return statement"
}
]
}