未读读取中的Fortify潜在缓冲区溢出

时间:2019-02-15 18:21:37

标签: c++ fortify unistd.h

Fortify说我的unistd.h read函数调用中存在潜在的缓冲区溢出。注意fd是一个类变量Code,如下所示:

std::size_t xyz::somefunction(const std::size_t numBytes, void* const buffer) throw (std::runtime_error)
{
    if(fd < 0)
        throw std::runtime_error("invalid file descriptor");
    return read(fd,buffer,numBytes);
}

Fortify报告read()作为接收器和污点标志,如NUMBER,STREAM,NOT_NULL_TERMINATED。

我无法在SO或Google上找到任何可以让我知道什么地方不对或需要对此进行更改的东西。

我最好的猜测是numBytes可能是>缓冲区的长度(以char *形式传递)

0 个答案:

没有答案