I think you should just allocate `CF_EXPANDSIZE` bytes here and read up to that limit.  CFEngine won't like it if you read too much data:

```
2013-10-23T19:09:11-0400    error: /test: Expansion overflow constructing string. Increase CF_EXPANDSIZE macro. Tried to add ' ...(full data omitted)'
2013-10-23T19:09:11-0400    error: /test: Fatal CFEngine error: Can't expand varstring
```

I think (personally) it's wrong to give a fatal error here.  But it's the situation today.