Rishi2Monk has asked for the wisdom of the Perl Monks concerning the following question:
Checkmarx, a static analyzer tool is throwing security issue with the below code, saying that $file_list is accessing Uncontrolled Memory Allocation.
open ( INFILE, "<", "$inputfile" ) || die( "Cannot read list file +$inputfile" ); while ( <INFILE> ) { $file = $_; chomp ( $file ); $file_list{$file} = "1"; }
I tried to restrict the size of the hash variable as mentioned below but the error is not resolved.
Kindly help me to understand the reason as the above code looks ok to me.if(length($file) <= (1 * 1024 * 1024)) { $file_list{$file} = "1"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Uncontrolled Memory Allocation (updated)
by haukex (Archbishop) on Sep 12, 2023 at 13:36 UTC | |
|
Re: Uncontrolled Memory Allocation
by bliako (Abbot) on Sep 12, 2023 at 14:14 UTC | |
by ikegami (Patriarch) on Sep 14, 2023 at 12:52 UTC | |
|
Re: Uncontrolled Memory Allocation
by Corion (Patriarch) on Sep 12, 2023 at 13:31 UTC | |
|
Re: Uncontrolled Memory Allocation
by karlgoethebier (Abbot) on Sep 13, 2023 at 20:59 UTC |