node_pcap icon indicating copy to clipboard operation
node_pcap copied to clipboard

decodeRR endless while loop on malformed dns rr

Open hillar opened this issue 10 years ago • 0 comments

on malformed packet it finally ends with

FATAL ERROR: JS Allocation failed - process out of memory

            while((ch = raw_packet[internal_offset++]) != 0x00) {
                result.name += String.fromCharCode(ch);
            }

checking ch for not undefined should fix it

            while((ch = raw_packet[internal_offset++]) != 0x00) {
                if (!ch) {
                        throw new Error("Malformed DNS RR. Offset is larger than the name length );
                }
                result.name += String.fromCharCode(ch);
            }

hillar avatar Mar 14 '14 14:03 hillar