编写Coverity模型:struct中的指针始终指向受污染的数据

Dir*_*ier 18 code-analysis coverity

我定期检查lwIP,一个带Coverity的免费TCP/IP堆栈.

作为网络堆栈,我们有来自网络的不受信任的数据,存储在struct pbuf中(为清楚起见,省略了一些成员):

struct pbuf {
  void *payload;
  u16_t len;
  u16_t ref;
};
Run Code Online (Sandbox Code Playgroud)

我的问题是:

1)我想模拟struct pbuf的"void*payload"始终指向受污染的数据,每次访问它都必须是不可信的.我怎样才能做到这一点?

2)我们使用refcounting(u16_t ref).有没有办法在Coverity中模拟引用计数?