Rishi2Monk has asked for the wisdom of the Perl Monks concerning the following question:

This node falls below the community's threshold of quality. You may see it by logging in.

Replies are listed 'Best First'.
Re: Uncontrolled Memory Allocation Error
by haukex (Archbishop) on Dec 27, 2022 at 13:43 UTC

    Unless someone here happens to know the tool you are using - from your previous posts I assume it's "Checkmarx" - we're not going to be able to explain it to you any better than the documentation of the tool, so I recommend you look there.

    open ( UNFILE, "<", "$file" ) || print ( "Cannot open file $file\n" );

    Your code will continue running even if the open fails. I already linked you to "open" Best Practices.

    $item_desc{$item_idx} = "$tmp_index.$temp_str\n$temp_desc";

    What are $item_idx and $tmp_index? It's their only use in this code. I hope this code uses strict and warnings... see also Short, Self-Contained, Correct Example and How do I post a question effectively?

    The better your questions, the faster you'll get good answers.

Re: Uncontrolled Memory Allocation Error
by Corion (Patriarch) on Dec 27, 2022 at 13:30 UTC

    The problem again is that you are reading from input that could be controlled by a user.

    A user might create a file with a line length that is longer than your machine or your application expects. If the user submits such a file to your program, it will try to read aa line (in the while loop) and will read "too much" data.

    To prevent that, you could limit the number of bytes that your program reads from a file at a time, for example by using read instead of readpipe (<UNFILE>).

Re: Uncontrolled Memory Allocation Error
by marto (Cardinal) on Dec 27, 2022 at 13:33 UTC

    You seem to be posting a lot of threads on this topic, while ignoring the responses to some degree. Have you escalated the fact that you aren't equipped to resolve these issues on your own?