read() - Check buffer boundaries if used in a loop including recursive loops
问题 I have this code and run it with Flawinder, and i get this output on the read() functions: "Check buffer boundaries if used in a loop including recursive loops" Can anyone see the problem? ** #include <stdlib.h> void func(int fd) { char *buf; size_t len; read(fd, &len, sizeof(len)); if (len > 1024) return; buf = malloc(len+1); read(fd, buf, len); buf[len] = '\0'; } ** 回答1: you should check the return value of read() to know whether call to read() was success or failure or if read() was