On 09/10/2012 09:26 PM, Wenchao Xia wrote: >>> +#define QB_ERR_STRING_SIZE (1024) >>> +struct QBroker { >>> + /* last error */ >>> + char err_msg[QB_ERR_STRING_SIZE]; >> >> Is this fixed-width struct going to bite us in the future? Suppose I >> pass in a file name that is already 1000 bytes long; it seems like I >> might be able to get you to overflow this buffer if your error message >> includes the name of my offending file. >> > Yes it will, thanks for mention me. The resource will always have a > limit, I guess I can just increase the size to 4k to solve the issue.
A 4k limit is still an easily reachable limit. PATH_MAX is typically 4k, and it is quite possible to create and access files in a hierarchy so deep that they are longer than PATH_MAX. I still think you are better off malloc'ing a pointer than trying to claim a fixed width field solves all possible messages. -- Eric Blake ebl...@redhat.com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature