What is the primary vulnerability in the following code?Single choice

Question Image
A

malloc should always be followed by calloc for safety

B

the null byte is added at the wrong index, which means the string is shorter by one character

C

Adding 1 to len may cause an integer overflow, leading to under allocation

D

malloc may allocate too much memory if len is zero

E

the function returns a void * type which means the values stored in the buffer are lost and it is a memory leak

F

The use of memcpy before null-termination is undefined behavior

Log in for full answers

We've collected over 50,000 authentic original questions and detailed explanations from around the globe. Log in now and get instant access to the answers!

Similar Questions

More Practical Tools for Students Powered by AI Study Helper

Join us and instantly unlock extensive past papers & exclusive solutions to get a head start on your studies!