libvirt/src/util
Cole Robinson 18af6f4e64 buf: Fix possible infinite loop in EscapeString, VSnprintf
The current code will go into an infinite loop if the printf generated
string is >= 1000, AND exactly 1 character smaller than the amount of free
space in the buffer. When this happens, we are dropped into the loop body,
but nothing will actually change, because count == (buf->size - buf->use - 1),
and virBufferGrow returns unchanged if count < (buf->size - buf->use)

Fix this by removing the '- 1' bit from 'size'. The *nprintf functions handle
the NULL byte for us anyways, so we shouldn't need to manually accommodate
for it.

Here's a bug where we are actually hitting this issue:
https://bugzilla.redhat.com/show_bug.cgi?id=602772

v2: Eric's improvements: while -> if (), remove extra va_list variable,
    make sure we report buffer error if snprintf fails

v3: Add tests/virbuftest which reproduces the infinite loop before this
    patch, works correctly after
2010-09-10 10:05:43 -04:00
..
authhelper.c esx: Move username and password helper functions to authhelper.c 2010-03-16 20:15:32 +01:00
authhelper.h esx: Move username and password helper functions to authhelper.c 2010-03-16 20:15:32 +01:00
bitmap.c Add ACK'd v2 changes for previous commit 2010-06-18 11:56:04 -04:00
bitmap.h build: fix cppi warnings 2010-05-21 16:02:18 -06:00
bridge.c Close fd's of persistent tap devices 2010-08-14 10:48:16 -06:00
bridge.h Set a stable & high MAC addr for guest TAP devices on host 2010-07-23 10:15:04 +01:00
buf.c buf: Fix possible infinite loop in EscapeString, VSnprintf 2010-09-10 10:05:43 -04:00
buf.h build: consistently indent preprocessor directives 2010-03-09 19:22:28 +01:00
cgroup.c cgroup: Fix compilation broken on MinGW due to dirent->d_type 2010-06-30 08:32:23 -06:00
cgroup.h build: consistently indent preprocessor directives 2010-03-09 19:22:28 +01:00
conf.c maint: add more free-like functions to the list and deal with fallout 2010-05-18 07:53:42 +02:00
conf.h build: consistently indent preprocessor directives 2010-03-09 19:22:28 +01:00
dnsmasq.c dnsmasqReload: avoid mingw link failure 2010-05-03 14:21:07 -06:00
dnsmasq.h Add dnsmasq module files 2010-04-26 17:20:02 +02:00
ebtables.c ebtablesAddRemoveRule, iptablesAddRemoveRule: don't skip va_end 2010-05-18 19:23:33 +02:00
ebtables.h build: consistently indent preprocessor directives 2010-03-09 19:22:28 +01:00
event.c Move all shared utility files to src/util/ 2009-09-21 14:41:47 +01:00
event.h build: consistently indent preprocessor directives 2010-03-09 19:22:28 +01:00
hash.c Fix up a comment in virHashUpdateEntry 2010-02-01 09:39:54 -05:00
hash.h build: consistently indent preprocessor directives 2010-03-09 19:22:28 +01:00
hooks.c hooks: fix typo 2010-05-28 06:54:28 -06:00
hooks.h Add hook utilities 2010-03-29 18:21:04 +02:00
hostusb.c hostusb: Properly handle 'usbX' sysfs files 2010-06-02 09:57:55 -04:00
hostusb.h build: consistently indent preprocessor directives 2010-03-09 19:22:28 +01:00
interface.c add 802.1Qbh and 802.1Qbg handling 2010-06-02 21:35:22 -04:00
interface.h add 802.1Qbh and 802.1Qbg handling 2010-06-02 21:35:22 -04:00
iptables.c Add iptables rule to fixup DHCP response checksum. 2010-08-02 11:34:14 -04:00
iptables.h Add iptables rule to fixup DHCP response checksum. 2010-08-02 11:34:14 -04:00
json.c build: consistently indent preprocessor directives 2010-03-09 19:22:28 +01:00
json.h build: consistently indent preprocessor directives 2010-03-09 19:22:28 +01:00
logging.c maint: don't mark VIR_WARN or VIR_WARN0 diagnostics for translation 2010-05-19 12:00:18 +02:00
logging.h build: consistently indent preprocessor directives 2010-03-09 19:22:28 +01:00
macvtap.c fix handling of PORT_PROFILE_RESPONSE_INPROGRESS netlink message 2010-07-28 16:17:21 +02:00
macvtap.h add 802.1Qbh and 802.1Qbg handling 2010-06-02 21:35:22 -04:00
memory.c Implement variable length structure allocator 2010-04-14 00:46:13 -04:00
memory.h maint: another preprocessor fix 2010-04-15 11:39:10 -06:00
network.c Extend virSocketParseAddr() to allow a NULL result pointer 2010-08-10 15:00:15 +02:00
network.h Use libvirt's existing ipv6/ipv4 parser/printer rather than self-written ones 2010-03-30 11:18:04 -04:00
pci.c Fix the ACS checking in the PCI code. 2010-08-02 09:54:38 -04:00
pci.h pciResetDevice: use inactive devices to determine safe reset 2010-07-26 18:43:04 +02:00
processinfo.c build: update gnulib 2010-05-06 14:35:38 -06:00
processinfo.h build: consistently indent preprocessor directives 2010-03-09 19:22:28 +01:00
qparams.c qparams.c: do not skip va_end, twice 2010-02-19 11:52:04 +01:00
qparams.h build: consistently indent preprocessor directives 2010-03-09 19:22:28 +01:00
stats_linux.c build: consistently indent preprocessor directives 2010-03-09 19:22:28 +01:00
stats_linux.h build: consistently indent preprocessor directives 2010-03-09 19:22:28 +01:00
storage_file.c Require format to be passed into virStorageFileGetMetadata 2010-07-19 18:25:04 +01:00
storage_file.h Require format to be passed into virStorageFileGetMetadata 2010-07-19 18:25:04 +01:00
threads-pthread.c Add recursive locks 2010-03-26 18:01:15 +00:00
threads-pthread.h Move all shared utility files to src/util/ 2009-09-21 14:41:47 +01:00
threads-win32.c build: avoid pthreads-win32 on mingw 2010-06-10 06:05:31 -06:00
threads-win32.h Move all shared utility files to src/util/ 2009-09-21 14:41:47 +01:00
threads.c build: avoid pthreads-win32 on mingw 2010-06-10 06:05:31 -06:00
threads.h build: avoid pthreads-win32 on mingw 2010-06-10 06:05:31 -06:00
util.c Move hextobin as virHexToBin to util.c 2010-08-30 22:21:54 +02:00
util.h Move hextobin as virHexToBin to util.c 2010-08-30 22:21:54 +02:00
uuid.c Move hextobin as virHexToBin to util.c 2010-08-30 22:21:54 +02:00
uuid.h Expose a host UUID in the capabilities XML 2010-05-25 17:09:18 +01:00
virterror_internal.h build: consistently indent preprocessor directives 2010-03-09 19:22:28 +01:00
virterror.c Improve some error messages about unsupported APIs/URIs 2010-06-23 14:07:39 +01:00
xml.c Introduce XML parsing utility functions 2010-03-23 15:40:04 +01:00
xml.h Introduce XML parsing utility functions 2010-03-23 15:40:04 +01:00