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
{
"ltable.c": [
{
"column": 1,
"file": "/home/brandon/toolchain/lua/ltable.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: (luaM_limitN(1 << MAXHBITS, Node))"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/ltable.c",
"line": 106,
"message": "Function-like macro 'hashpow2' 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/ltable.c",
"line": 106,
"message": "Macro evaluates parameter 't' 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/ltable.c",
"line": 112,
"message": "Function-like macro 'hashmod' 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/ltable.c",
"line": 112,
"message": "Macro evaluates parameter 't' multiple times; use inline function instead",
"rule_id": "PRE12-C",
"severity": "Medium",
"suggestion": "Replace macro with inline function to avoid multiple evaluation"
},
{
"column": 21,
"file": "/home/brandon/toolchain/lua/ltable.c",
"line": 148,
"message": "Variable 'sizenode' 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": 21,
"file": "/home/brandon/toolchain/lua/ltable.c",
"line": 148,
"message": "Variable 't' 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": 21,
"file": "/home/brandon/toolchain/lua/ltable.c",
"line": 148,
"message": "Division or modulo by 'cast_int((sizenode(t)-1) | 1)' without checking for zero",
"rule_id": "INT33-C",
"severity": "High",
"suggestion": "Check if 'cast_int((sizenode(t)-1) | 1)' is not zero before division"
},
{
"column": 34,
"file": "/home/brandon/toolchain/lua/ltable.c",
"line": 148,
"message": "Modulo operator used with potentially signed operands. The result of % with negative operands is implementation-defined and can be negative. Use unsigned types (size_t, unsigned int) or explicitly handle negative remainders.",
"rule_id": "INT10-C",
"severity": "Medium",
"suggestion": "Convert operands to unsigned types (size_t, unsigned int) or add explicit checks for negative values"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/ltable.c",
"line": 226,
"message": "Function 'mainpositionfromnode' does not validate pointer parameter 't' before use",
"rule_id": "API00-C",
"severity": "Medium",
"suggestion": "Add validation check for 't' at the start of the function, e.g., 'if (!t) { return error_code; }'"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/ltable.c",
"line": 226,
"message": "Function 'mainpositionfromnode' does not validate pointer parameter 'nd' before use",
"rule_id": "API00-C",
"severity": "Medium",
"suggestion": "Add validation check for 'nd' at the start of the function, e.g., 'if (!nd) { return error_code; }'"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/ltable.c",
"line": 226,
"message": "Function 'mainpositionfromnode' 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 mainpositionfromnode"
},
{
"column": 60,
"file": "/home/brandon/toolchain/lua/ltable.c",
"line": 226,
"message": "Pointer parameter 'nd' is not modified and should be declared const",
"rule_id": "DCL13-C",
"severity": "Low",
"suggestion": "Declare parameter as 'const <type> *nd'"
},
{
"column": 14,
"file": "/home/brandon/toolchain/lua/ltable.c",
"line": 256,
"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": 16,
"file": "/home/brandon/toolchain/lua/ltable.c",
"line": 272,
"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": 16,
"file": "/home/brandon/toolchain/lua/ltable.c",
"line": 278,
"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/ltable.c",
"line": 291,
"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/ltable.c",
"line": 326,
"message": "Macro parameter 't' is not parenthesized in replacement text. This can cause operator precedence issues.",
"rule_id": "PRE01-C",
"severity": "Medium",
"suggestion": "Wrap parameter 't' in parentheses: (t) instead of t"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/ltable.c",
"line": 361,
"message": "Function 'luaH_next' 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/ltable.c",
"line": 361,
"message": "Function 'luaH_next' does not validate pointer parameter 't' before use",
"rule_id": "API00-C",
"severity": "Medium",
"suggestion": "Add validation check for 't' at the start of the function, e.g., 'if (!t) { return error_code; }'"
},
{
"column": 28,
"file": "/home/brandon/toolchain/lua/ltable.c",
"line": 397,
"message": "Use-after-free: passing freed pointer 't' to function",
"rule_id": "MEM30-C",
"severity": "Critical",
"suggestion": "Do not pass freed memory to functions."
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/ltable.c",
"line": 479,
"message": "Function 'arraykeyisempty' does not validate pointer parameter 't' before use",
"rule_id": "API00-C",
"severity": "Medium",
"suggestion": "Add validation check for 't' at the start of the function, e.g., 'if (!t) { return error_code; }'"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/ltable.c",
"line": 479,
"message": "Function 'arraykeyisempty' does not validate integer parameter 'key' for overflow before arithmetic operations",
"rule_id": "API00-C",
"severity": "Medium",
"suggestion": "Add overflow validation for 'key' before arithmetic, e.g., check against INT_MAX/INT_MIN or use __builtin_*_overflow()"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/ltable.c",
"line": 479,
"message": "Function 'arraykeyisempty' 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 arraykeyisempty"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/ltable.c",
"line": 479,
"message": "Function 'arraykeyisempty' 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 'arraykeyisempty'"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/ltable.c",
"line": 544,
"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": 12,
"file": "/home/brandon/toolchain/lua/ltable.c",
"line": 548,
"message": "Scaled integer arithmetic with pointer: 'size * (sizeof(Value) + 1) + sizeof(unsigned)'. This results in double scaling",
"rule_id": "ARR39-C",
"severity": "High",
"suggestion": "Remove sizeof() or use unscaled integer arithmetic"
},
{
"column": 49,
"file": "/home/brandon/toolchain/lua/ltable.c",
"line": 563,
"message": "Pointer parameter 't' is not modified and should be declared const",
"rule_id": "DCL13-C",
"severity": "Low",
"suggestion": "Declare parameter as 'const <type> *t'"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/ltable.c",
"line": 602,
"message": "Function 'setnodevector' participates in indirect recursion: setnodevector -> luaG_runerror -> luaG_errormsg -> luaD_callnoyield -> ccall -> luaV_execute -> luaH_new -> setnodevector",
"rule_id": "MSC04-C",
"severity": "Medium",
"suggestion": "Refactor to eliminate the recursion cycle"
},
{
"column": 30,
"file": "/home/brandon/toolchain/lua/ltable.c",
"line": 611,
"message": "Shift operation '1 << lsize' by 'lsize' without validating shift amount is non-negative and within type width",
"rule_id": "INT34-C",
"severity": "Medium",
"suggestion": "Check that 'lsize' is >= 0 and < the bit width of the operand before shifting"
},
{
"column": 35,
"file": "/home/brandon/toolchain/lua/ltable.c",
"line": 611,
"message": "Bitwise operator '<<' used on signed operand 'lsize' of type 'int'. Use unsigned types for bitwise operations",
"rule_id": "INT13-C",
"severity": "Medium",
"suggestion": "Change 'lsize' to an unsigned type (e.g., 'unsigned int' instead of 'int')"
},
{
"column": 22,
"file": "/home/brandon/toolchain/lua/ltable.c",
"line": 617,
"message": "Scaled integer arithmetic with pointer: 'size * sizeof(Node) + sizeof(Limbox)'. This results in double scaling",
"rule_id": "ARR39-C",
"severity": "High",
"suggestion": "Remove sizeof() or use unscaled integer arithmetic"
},
{
"column": 22,
"file": "/home/brandon/toolchain/lua/ltable.c",
"line": 619,
"message": "Scaled integer arithmetic with pointer: 'Node *, node + sizeof(Limbox)'. This results in double scaling",
"rule_id": "ARR39-C",
"severity": "High",
"suggestion": "Remove sizeof() or use unscaled integer arithmetic"
},
{
"column": 24,
"file": "/home/brandon/toolchain/lua/ltable.c",
"line": 620,
"message": "Use-after-free: passing freed pointer 't' to function",
"rule_id": "MEM30-C",
"severity": "Critical",
"suggestion": "Do not pass freed memory to functions."
},
{
"column": 5,
"file": "/home/brandon/toolchain/lua/ltable.c",
"line": 623,
"message": "Use-after-free: passing freed pointer 't' to function",
"rule_id": "MEM30-C",
"severity": "Critical",
"suggestion": "Do not pass freed memory to functions."
},
{
"column": 17,
"file": "/home/brandon/toolchain/lua/ltable.c",
"line": 625,
"message": "Use-after-free: passing freed pointer 't' to function",
"rule_id": "MEM30-C",
"severity": "Critical",
"suggestion": "Do not pass freed memory to functions."
},
{
"column": 53,
"file": "/home/brandon/toolchain/lua/ltable.c",
"line": 667,
"message": "Bitwise operator '|' used on signed operand 'bitdummy1' of type 'int'. Use unsigned types for bitwise operations",
"rule_id": "INT13-C",
"severity": "Medium",
"suggestion": "Change 'bitdummy1' to an unsigned type (e.g., 'unsigned int' instead of 'int')"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/ltable.c",
"line": 715,
"message": "Function 'luaH_resize' 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/ltable.c",
"line": 715,
"message": "Function 'luaH_resize' does not validate pointer parameter 't' before use",
"rule_id": "API00-C",
"severity": "Medium",
"suggestion": "Add validation check for 't' at the start of the function, e.g., 'if (!t) { return error_code; }'"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/ltable.c",
"line": 715,
"message": "Function 'luaH_resize' participates in indirect recursion: luaH_resize -> luaG_runerror -> luaG_errormsg -> luaD_callnoyield -> ccall -> luaV_execute -> luaH_resizearray -> luaH_resize",
"rule_id": "MSC04-C",
"severity": "Medium",
"suggestion": "Refactor to eliminate the recursion cycle"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/ltable.c",
"line": 750,
"message": "Function 'luaH_resizearray' 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/ltable.c",
"line": 750,
"message": "Function 'luaH_resizearray' does not validate pointer parameter 't' before use",
"rule_id": "API00-C",
"severity": "Medium",
"suggestion": "Add validation check for 't' at the start of the function, e.g., 'if (!t) { return error_code; }'"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/ltable.c",
"line": 750,
"message": "Function 'luaH_resizearray' participates in indirect recursion: luaH_resizearray -> luaH_resize -> luaG_runerror -> luaG_errormsg -> luaD_callnoyield -> ccall -> luaV_execute -> luaH_resizearray",
"rule_id": "MSC04-C",
"severity": "Medium",
"suggestion": "Refactor to eliminate the recursion cycle"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/ltable.c",
"line": 761,
"message": "Function 'rehash' participates in indirect recursion: rehash -> luaH_resize -> luaG_runerror -> luaG_errormsg -> luaD_callnoyield -> ccall -> luaV_execute -> luaT_adjustvarargs -> createvarargtab -> luaH_set -> luaH_finishset -> luaH_newkey -> rehash",
"rule_id": "MSC04-C",
"severity": "Medium",
"suggestion": "Refactor to eliminate the recursion cycle"
},
{
"column": 35,
"file": "/home/brandon/toolchain/lua/ltable.c",
"line": 767,
"message": "Variable 'ct' may be used uninitialized (not assigned on all paths)",
"rule_id": "EXP33-C",
"severity": "High",
"suggestion": "Initialize 'ct' before use, e.g., at its declaration"
},
{
"column": 5,
"file": "/home/brandon/toolchain/lua/ltable.c",
"line": 787,
"message": "Variable 'nsize' 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/ltable.c",
"line": 798,
"message": "Function 'luaH_new' 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/ltable.c",
"line": 798,
"message": "Function 'luaH_new' participates in indirect recursion: luaH_new -> setnodevector -> luaG_runerror -> luaG_errormsg -> luaD_callnoyield -> ccall -> luaV_execute -> luaH_new",
"rule_id": "MSC04-C",
"severity": "Medium",
"suggestion": "Refactor to eliminate the recursion cycle"
},
{
"column": 3,
"file": "/home/brandon/toolchain/lua/ltable.c",
"line": 806,
"message": "Function returns pointer to local variable 't' 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/ltable.c",
"line": 810,
"message": "Function 'luaH_size' does not validate pointer parameter 't' before use",
"rule_id": "API00-C",
"severity": "Medium",
"suggestion": "Add validation check for 't' at the start of the function, e.g., 'if (!t) { return error_code; }'"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/ltable.c",
"line": 821,
"message": "Function 'luaH_free' 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/ltable.c",
"line": 821,
"message": "Function 'luaH_free' does not validate pointer parameter 't' before use",
"rule_id": "API00-C",
"severity": "Medium",
"suggestion": "Add validation check for 't' at the start of the function, e.g., 'if (!t) { return error_code; }'"
},
{
"column": 3,
"file": "/home/brandon/toolchain/lua/ltable.c",
"line": 823,
"message": "Use-after-free: passing freed pointer 't' to function",
"rule_id": "MEM30-C",
"severity": "Critical",
"suggestion": "Do not pass freed memory to functions."
},
{
"column": 3,
"file": "/home/brandon/toolchain/lua/ltable.c",
"line": 823,
"message": "Use-after-free: passing freed pointer 't' to function",
"rule_id": "MEM30-C",
"severity": "Critical",
"suggestion": "Do not pass freed memory to functions."
},
{
"column": 21,
"file": "/home/brandon/toolchain/lua/ltable.c",
"line": 823,
"message": "Use-after-free: accessing member of freed pointer 't'",
"rule_id": "MEM30-C",
"severity": "Critical",
"suggestion": "Do not access members of freed memory."
},
{
"column": 3,
"file": "/home/brandon/toolchain/lua/ltable.c",
"line": 824,
"message": "Double-free: 't' freed multiple times",
"rule_id": "MEM30-C",
"severity": "Critical",
"suggestion": "Set pointer to NULL after freeing to prevent double-free."
},
{
"column": 12,
"file": "/home/brandon/toolchain/lua/ltable.c",
"line": 831,
"message": "Double-free: 't' freed multiple times",
"rule_id": "MEM30-C",
"severity": "Critical",
"suggestion": "Set pointer to NULL after freeing to prevent double-free."
},
{
"column": 29,
"file": "/home/brandon/toolchain/lua/ltable.c",
"line": 831,
"message": "Use-after-free: accessing member of freed pointer 't'",
"rule_id": "MEM30-C",
"severity": "Critical",
"suggestion": "Do not access members of freed memory."
},
{
"column": 22,
"file": "/home/brandon/toolchain/lua/ltable.c",
"line": 832,
"message": "Double-free: 't' freed multiple times",
"rule_id": "MEM30-C",
"severity": "Critical",
"suggestion": "Set pointer to NULL after freeing to prevent double-free."
},
{
"column": 18,
"file": "/home/brandon/toolchain/lua/ltable.c",
"line": 838,
"message": "Use-after-free: passing freed pointer 't' to function",
"rule_id": "MEM30-C",
"severity": "Critical",
"suggestion": "Do not pass freed memory to functions."
},
{
"column": 20,
"file": "/home/brandon/toolchain/lua/ltable.c",
"line": 840,
"message": "Use-after-free: passing freed pointer 't' to function",
"rule_id": "MEM30-C",
"severity": "Critical",
"suggestion": "Do not pass freed memory to functions."
},
{
"column": 59,
"file": "/home/brandon/toolchain/lua/ltable.c",
"line": 858,
"message": "Pointer parameter 'value' is not modified and should be declared const",
"rule_id": "DCL13-C",
"severity": "Low",
"suggestion": "Declare parameter as 'const <type> *value'"
},
{
"column": 17,
"file": "/home/brandon/toolchain/lua/ltable.c",
"line": 867,
"message": "Use-after-free: passing freed pointer 't' to function",
"rule_id": "MEM30-C",
"severity": "Critical",
"suggestion": "Do not pass freed memory to functions."
},
{
"column": 14,
"file": "/home/brandon/toolchain/lua/ltable.c",
"line": 868,
"message": "Use-after-free: passing freed pointer 't' to function",
"rule_id": "MEM30-C",
"severity": "Critical",
"suggestion": "Do not pass freed memory to functions."
},
{
"column": 7,
"file": "/home/brandon/toolchain/lua/ltable.c",
"line": 874,
"message": "Direct assignment of flexible array structure instances. Use memcpy() for dynamic copying.",
"rule_id": "MEM33-C",
"severity": "High",
"suggestion": "Use memcpy() to copy the structure and its flexible array member"
},
{
"column": 12,
"file": "/home/brandon/toolchain/lua/ltable.c",
"line": 874,
"message": "Potential null pointer dereference of variable 'mp'",
"rule_id": "EXP34-C",
"severity": "High",
"suggestion": "Check if 'mp' is not NULL before dereferencing"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/ltable.c",
"line": 913,
"message": "Function 'luaH_newkey' participates in indirect recursion: luaH_newkey -> rehash -> luaH_resize -> luaG_runerror -> luaG_errormsg -> luaD_callnoyield -> ccall -> luaV_execute -> luaT_adjustvarargs -> createvarargtab -> luaH_set -> luaH_finishset -> luaH_newkey",
"rule_id": "MSC04-C",
"severity": "Medium",
"suggestion": "Refactor to eliminate the recursion cycle"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/ltable.c",
"line": 958,
"message": "Function 'luaH_getint' does not validate pointer parameter 't' before use",
"rule_id": "API00-C",
"severity": "Medium",
"suggestion": "Add validation check for 't' at the start of the function, e.g., 'if (!t) { return error_code; }'"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/ltable.c",
"line": 974,
"message": "Function 'luaH_Hgetshortstr' does not validate pointer parameter 't' before use",
"rule_id": "API00-C",
"severity": "Medium",
"suggestion": "Add validation check for 't' at the start of the function, e.g., 'if (!t) { return error_code; }'"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/ltable.c",
"line": 974,
"message": "Function 'luaH_Hgetshortstr' does not validate pointer parameter 'key' before use",
"rule_id": "API00-C",
"severity": "Medium",
"suggestion": "Add validation check for 'key' at the start of the function, e.g., 'if (!key) { return error_code; }'"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/ltable.c",
"line": 974,
"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/ltable.c",
"line": 990,
"message": "Function 'luaH_getshortstr' does not validate pointer parameter 't' before use",
"rule_id": "API00-C",
"severity": "Medium",
"suggestion": "Add validation check for 't' at the start of the function, e.g., 'if (!t) { return error_code; }'"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/ltable.c",
"line": 990,
"message": "Function 'luaH_getshortstr' does not validate pointer parameter 'key' before use",
"rule_id": "API00-C",
"severity": "Medium",
"suggestion": "Add validation check for 'key' at the start of the function, e.g., 'if (!key) { return error_code; }'"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/ltable.c",
"line": 990,
"message": "Function 'luaH_getshortstr' does not validate pointer parameter 'res' before use",
"rule_id": "API00-C",
"severity": "Medium",
"suggestion": "Add validation check for 'res' at the start of the function, e.g., 'if (!res) { return error_code; }'"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/ltable.c",
"line": 1011,
"message": "Function 'luaH_getstr' does not validate pointer parameter 't' before use",
"rule_id": "API00-C",
"severity": "Medium",
"suggestion": "Add validation check for 't' at the start of the function, e.g., 'if (!t) { return error_code; }'"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/ltable.c",
"line": 1011,
"message": "Function 'luaH_getstr' does not validate pointer parameter 'key' before use",
"rule_id": "API00-C",
"severity": "Medium",
"suggestion": "Add validation check for 'key' at the start of the function, e.g., 'if (!key) { return error_code; }'"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/ltable.c",
"line": 1011,
"message": "Function 'luaH_getstr' does not validate pointer parameter 'res' before use",
"rule_id": "API00-C",
"severity": "Medium",
"suggestion": "Add validation check for 'res' at the start of the function, e.g., 'if (!res) { return error_code; }'"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/ltable.c",
"line": 1019,
"message": "Function 'luaH_get' does not validate pointer parameter 't' before use",
"rule_id": "API00-C",
"severity": "Medium",
"suggestion": "Add validation check for 't' at the start of the function, e.g., 'if (!t) { return error_code; }'"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/ltable.c",
"line": 1019,
"message": "Function 'luaH_get' does not validate pointer parameter 'key' before use",
"rule_id": "API00-C",
"severity": "Medium",
"suggestion": "Add validation check for 'key' at the start of the function, e.g., 'if (!key) { return error_code; }'"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/ltable.c",
"line": 1019,
"message": "Function 'luaH_get' does not validate pointer parameter 'res' before use",
"rule_id": "API00-C",
"severity": "Medium",
"suggestion": "Add validation check for 'res' at the start of the function, e.g., 'if (!res) { return error_code; }'"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/ltable.c",
"line": 1048,
"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": 31,
"file": "/home/brandon/toolchain/lua/ltable.c",
"line": 1048,
"message": "Pointer parameter 't' is not modified and should be declared const",
"rule_id": "DCL13-C",
"severity": "Low",
"suggestion": "Declare parameter as 'const <type> *t'"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/ltable.c",
"line": 1076,
"message": "Function 'luaH_psetint' does not validate pointer parameter 't' before use",
"rule_id": "API00-C",
"severity": "Medium",
"suggestion": "Add validation check for 't' at the start of the function, e.g., 'if (!t) { return error_code; }'"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/ltable.c",
"line": 1076,
"message": "Function 'luaH_psetint' does not validate pointer parameter 'val' before use",
"rule_id": "API00-C",
"severity": "Medium",
"suggestion": "Add validation check for 'val' at the start of the function, e.g., 'if (!val) { return error_code; }'"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/ltable.c",
"line": 1097,
"message": "Function 'luaH_psetshortstr' does not validate pointer parameter 'key' before use",
"rule_id": "API00-C",
"severity": "Medium",
"suggestion": "Add validation check for 'key' at the start of the function, e.g., 'if (!key) { return error_code; }'"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/ltable.c",
"line": 1131,
"message": "Function 'luaH_pset' does not validate pointer parameter 't' before use",
"rule_id": "API00-C",
"severity": "Medium",
"suggestion": "Add validation check for 't' at the start of the function, e.g., 'if (!t) { return error_code; }'"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/ltable.c",
"line": 1131,
"message": "Function 'luaH_pset' does not validate pointer parameter 'key' before use",
"rule_id": "API00-C",
"severity": "Medium",
"suggestion": "Add validation check for 'key' at the start of the function, e.g., 'if (!key) { return error_code; }'"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/ltable.c",
"line": 1131,
"message": "Function 'luaH_pset' does not validate pointer parameter 'val' before use",
"rule_id": "API00-C",
"severity": "Medium",
"suggestion": "Add validation check for 'val' at the start of the function, e.g., 'if (!val) { return error_code; }'"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/ltable.c",
"line": 1153,
"message": "Function 'luaH_finishset' 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/ltable.c",
"line": 1153,
"message": "Function 'luaH_finishset' participates in indirect recursion: luaH_finishset -> luaS_normstr -> internshrstr -> growstrtab -> luaC_fullgc -> fullgen -> entergen -> atomic2gen -> finishgencycle -> luaD_checkminstack -> luaD_growstack -> luaG_runerror -> luaG_errormsg -> luaD_callnoyield -> ccall -> luaV_execute -> luaT_adjustvarargs -> createvarargtab -> luaH_set -> luaH_finishset",
"rule_id": "MSC04-C",
"severity": "Medium",
"suggestion": "Refactor to eliminate the recursion cycle"
},
{
"column": 31,
"file": "/home/brandon/toolchain/lua/ltable.c",
"line": 1182,
"message": "Variable 'hres' 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": 13,
"file": "/home/brandon/toolchain/lua/ltable.c",
"line": 1185,
"message": "Bitwise operator '~' used on signed operand 'hres' of type 'int'. Use unsigned types for bitwise operations",
"rule_id": "INT13-C",
"severity": "Medium",
"suggestion": "Change 'hres' to an unsigned type (e.g., 'unsigned int' instead of 'int')"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/ltable.c",
"line": 1195,
"message": "Function 'luaH_set' does not validate pointer parameter 't' before use",
"rule_id": "API00-C",
"severity": "Medium",
"suggestion": "Add validation check for 't' at the start of the function, e.g., 'if (!t) { return error_code; }'"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/ltable.c",
"line": 1195,
"message": "Function 'luaH_set' does not validate pointer parameter 'key' before use",
"rule_id": "API00-C",
"severity": "Medium",
"suggestion": "Add validation check for 'key' at the start of the function, e.g., 'if (!key) { return error_code; }'"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/ltable.c",
"line": 1195,
"message": "Function 'luaH_set' does not validate pointer parameter 'value' before use",
"rule_id": "API00-C",
"severity": "Medium",
"suggestion": "Add validation check for 'value' at the start of the function, e.g., 'if (!value) { return error_code; }'"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/ltable.c",
"line": 1195,
"message": "Function 'luaH_set' participates in indirect recursion: luaH_set -> luaH_finishset -> luaS_normstr -> internshrstr -> growstrtab -> luaC_fullgc -> fullgen -> entergen -> atomic2gen -> finishgencycle -> luaD_checkminstack -> luaD_growstack -> luaG_runerror -> luaG_errormsg -> luaD_callnoyield -> ccall -> luaV_execute -> luaT_adjustvarargs -> createvarargtab -> luaH_set",
"rule_id": "MSC04-C",
"severity": "Medium",
"suggestion": "Refactor to eliminate the recursion cycle"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/ltable.c",
"line": 1206,
"message": "Function 'luaH_setint' does not validate pointer parameter 't' before use",
"rule_id": "API00-C",
"severity": "Medium",
"suggestion": "Add validation check for 't' at the start of the function, e.g., 'if (!t) { return error_code; }'"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/ltable.c",
"line": 1206,
"message": "Function 'luaH_setint' participates in indirect recursion: luaH_setint -> luaH_newkey -> rehash -> luaH_resize -> luaG_runerror -> luaG_errormsg -> luaD_callnoyield -> ccall -> luaV_execute -> luaT_adjustvarargs -> createvarargtab -> luaH_setint",
"rule_id": "MSC04-C",
"severity": "Medium",
"suggestion": "Refactor to eliminate the recursion cycle"
},
{
"column": 19,
"file": "/home/brandon/toolchain/lua/ltable.c",
"line": 1243,
"message": "Variable 'n' 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": 20,
"file": "/home/brandon/toolchain/lua/ltable.c",
"line": 1243,
"message": "Shift operation '1u << n' by 'n' without validating shift amount is non-negative and within type width",
"rule_id": "INT34-C",
"severity": "Medium",
"suggestion": "Check that 'n' is >= 0 and < the bit width of the operand before shifting"
},
{
"column": 26,
"file": "/home/brandon/toolchain/lua/ltable.c",
"line": 1243,
"message": "Bitwise operator '<<' used on signed operand 'n' of type 'int'. Use unsigned types for bitwise operations",
"rule_id": "INT13-C",
"severity": "Medium",
"suggestion": "Change 'n' to an unsigned type (e.g., 'unsigned int' instead of 'int')"
},
{
"column": 19,
"file": "/home/brandon/toolchain/lua/ltable.c",
"line": 1244,
"message": "Variable 'mask' 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": 19,
"file": "/home/brandon/toolchain/lua/ltable.c",
"line": 1244,
"message": "Variable 'rnd' 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/ltable.c",
"line": 1262,
"message": "Subtracting pointers from different arrays ('j' from 'LUA_MAXINTEGER' and 'i' from 'j'). Pointer subtraction is only defined for pointers within the same array object.",
"rule_id": "ARR00-C",
"severity": "Medium",
"suggestion": "Only subtract pointers that point to elements within the same array object."
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/ltable.c",
"line": 1301,
"message": "Function 'luaH_getn' 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_Unsigned luaH_getn"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/ltable.c",
"line": 1301,
"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/ltable.c",
"line": 1351,
"message": "Function 'luaH_mainposition' does not validate pointer parameter 't' before use",
"rule_id": "API00-C",
"severity": "Medium",
"suggestion": "Add validation check for 't' at the start of the function, e.g., 'if (!t) { return error_code; }'"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/ltable.c",
"line": 1351,
"message": "Function 'luaH_mainposition' does not validate pointer parameter 'key' before use",
"rule_id": "API00-C",
"severity": "Medium",
"suggestion": "Add validation check for 'key' at the start of the function, e.g., 'if (!key) { return error_code; }'"
}
]
}