mirror of
https://github.com/samba-team/samba.git
synced 2025-01-04 05:18:06 +03:00
global_globber_region_function/line ought to be recorded before
clobbering the region, just in case clobbering causes us to crash immediately. (That might happen if we just shot ourselves in the stack and strcpy was not inlined.) Also, in DEVELOPER mode and when Valgrind is available, mark the clobbered region as uninitialized. This is an even stronger protection than clobbering with 0xf1.
This commit is contained in:
parent
e1baab1ee0
commit
5653a42ae6
@ -424,15 +424,27 @@ size_t count_chars(const char *s,char c)
|
||||
*
|
||||
* This is meant to catch possible string overflows, even if the
|
||||
* actual string copied is not big enough to cause an overflow.
|
||||
*
|
||||
* In addition, under Valgrind the buffer is marked as uninitialized.
|
||||
**/
|
||||
void clobber_region(const char *fn, unsigned int line, char *dest, size_t len)
|
||||
{
|
||||
#ifdef DEVELOPER
|
||||
/* F1 is odd and 0xf1f1f1f1 shouldn't be a valid pointer */
|
||||
memset(dest, 0xF1, len);
|
||||
global_clobber_region_function = fn;
|
||||
global_clobber_region_line = line;
|
||||
#endif
|
||||
|
||||
/* F1 is odd and 0xf1f1f1f1 shouldn't be a valid pointer */
|
||||
memset(dest, 0xF1, len);
|
||||
#ifdef VALGRIND
|
||||
/* Even though we just wrote to this, from the application's
|
||||
* point of view it is not initialized.
|
||||
*
|
||||
* (This is not redundant with the clobbering above. The
|
||||
* marking might not actually take effect if we're not running
|
||||
* under valgrind or not with --client-perms.) */
|
||||
VALGRIND_MAKE_WRITABLE(dest, len);
|
||||
#endif /* VALGRIND */
|
||||
#endif /* DEVELOPER */
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user