diff options
author | Eric Blake <eblake@redhat.com> | 2011-09-20 12:11:32 -0600 |
---|---|---|
committer | Daniel Veillard <veillard@redhat.com> | 2011-09-21 16:17:20 +0800 |
commit | 2b0803c64f8fdbbbf0f135ef9be610579fd8fe8f (patch) | |
tree | 41381d10510e97d91c3a7a80d4cd172fa1331e73 /cfg.mk | |
parent | xen: use typical allocations (diff) | |
download | libvirt-2b0803c64f8fdbbbf0f135ef9be610579fd8fe8f.tar.gz libvirt-2b0803c64f8fdbbbf0f135ef9be610579fd8fe8f.tar.bz2 libvirt-2b0803c64f8fdbbbf0f135ef9be610579fd8fe8f.zip |
remote: fix crash on OOM
Bug introduced in commit 675464b. On an OOM, this would try to
dereference a char* and free the contents as a pointer, which is
doomed to failure.
Adding a syntax check will prevent mistakes like this in the future.
* cfg.mk (sc_prohibit_internal_functions): New syntax check.
(exclude_file_name_regexp--sc_prohibit_internal_functions): Add
exemptions.
* daemon/remote.c (remoteRelayDomainEventIOError)
(remoteRelayDomainEventIOErrorReason)
(remoteRelayDomainEventGraphics, remoteRelayDomainEventBlockJob):
Use correct free function.
Diffstat (limited to 'cfg.mk')
-rw-r--r-- | cfg.mk | 11 |
1 files changed, 10 insertions, 1 deletions
@@ -212,7 +212,7 @@ useless_free_options = \ # y virDomainWatchdogDefFree # n virDrvNodeGetCellsFreeMemory (returns int) # n virDrvNodeGetFreeMemory (returns long long) -# n virFree (dereferences param) +# n virFree - dereferences param # n virFreeError # n virHashFree (takes 2 args) # y virInterfaceDefFree @@ -306,6 +306,12 @@ sc_flags_usage: halt='flags should be unsigned' \ $(_sc_search_regexp) +# Avoid functions that should only be called via macro counterparts. +sc_prohibit_internal_functions: + @prohibit='vir(Free|AllocN?|ReallocN|File(Close|Fclose|Fdopen)) *\(' \ + halt='use VIR_ macros instead of internal functions' \ + $(_sc_search_regexp) + # Avoid functions that can lead to double-close bugs. sc_prohibit_close: @prohibit='([^>.]|^)\<[fp]?close *\(' \ @@ -706,6 +712,9 @@ exclude_file_name_regexp--sc_prohibit_fork_wrappers = \ exclude_file_name_regexp--sc_prohibit_gethostname = ^src/util/util\.c$$ +exclude_file_name_regexp--sc_prohibit_internal_functions = \ + ^src/(util/(memory|util|virfile)\.[hc]|esx/esx_vi\.c)$$ + exclude_file_name_regexp--sc_prohibit_newline_at_end_of_diagnostic = \ ^src/rpc/gendispatch\.pl$$ |