What is the primary vulnerability in the following code?单项选择题

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
登录即可查看完整答案
我们收录了全球超50000道真实原题与详细解析,现在登录,立即获得答案。
类似问题
Which of the following is a potential issue when computing mid = (low + high) // 2 for very large lists?
When might you encounter a problem with integer overflow? 什么时候可能会遇到整数溢出问题?
An overflow error takes place when:
Consider the following code: long y = 9223372036854775807L; y = y + 1; System.out.println(y); What number does the program print when compiled and run? Hint: think about the max value you just looked up in your previous answer.
更多留学生实用工具
希望你的学习变得更简单
加入我们,立即解锁 海量真题 与 独家解析,让复习快人一步!