|
Mark Wielaard |
8b9a72 |
commit d67f20debc80ad98c76b0edb8fc44002ca9ea0cd
|
|
Mark Wielaard |
8b9a72 |
Author: Mark Wielaard <mjw@redhat.com>
|
|
Mark Wielaard |
8b9a72 |
Date: Tue May 13 15:07:52 2014 +0200
|
|
Mark Wielaard |
8b9a72 |
|
|
Mark Wielaard |
8b9a72 |
Use safe_to_deref in coregrind syswrap-generic.c (msghdr_foreachfield).
|
|
Mark Wielaard |
8b9a72 |
|
|
Mark Wielaard |
8b9a72 |
Call ML_(safe_to_deref) before using msghdr msg_name, msg_iov or msg_control.
|
|
Mark Wielaard |
8b9a72 |
Fixes bug #334705.
|
|
Mark Wielaard |
8b9a72 |
|
|
Mark Wielaard |
8b9a72 |
diff --git a/coregrind/m_syswrap/syswrap-generic.c b/coregrind/m_syswrap/syswrap-generic.c
|
|
Mark Wielaard |
8b9a72 |
index cdf64ea..f1207f4 100644
|
|
Mark Wielaard |
8b9a72 |
--- a/coregrind/m_syswrap/syswrap-generic.c
|
|
Mark Wielaard |
8b9a72 |
+++ b/coregrind/m_syswrap/syswrap-generic.c
|
|
Mark Wielaard |
8b9a72 |
@@ -951,13 +951,15 @@ void msghdr_foreachfield (
|
|
Mark Wielaard |
8b9a72 |
if ( recv )
|
|
Mark Wielaard |
8b9a72 |
foreach_func ( tid, False, fieldName, (Addr)&msg->msg_flags, sizeof( msg->msg_flags ) );
|
|
Mark Wielaard |
8b9a72 |
|
|
Mark Wielaard |
8b9a72 |
- if ( msg->msg_name ) {
|
|
Mark Wielaard |
8b9a72 |
+ if ( ML_(safe_to_deref)(&msg->msg_name, sizeof (void *))
|
|
Mark Wielaard |
8b9a72 |
+ && msg->msg_name ) {
|
|
Mark Wielaard |
8b9a72 |
VG_(sprintf) ( fieldName, "(%s.msg_name)", name );
|
|
Mark Wielaard |
8b9a72 |
foreach_func ( tid, False, fieldName,
|
|
Mark Wielaard |
8b9a72 |
(Addr)msg->msg_name, msg->msg_namelen );
|
|
Mark Wielaard |
8b9a72 |
}
|
|
Mark Wielaard |
8b9a72 |
|
|
Mark Wielaard |
8b9a72 |
- if ( msg->msg_iov ) {
|
|
Mark Wielaard |
8b9a72 |
+ if ( ML_(safe_to_deref)(&msg->msg_iov, sizeof (void *))
|
|
Mark Wielaard |
8b9a72 |
+ && msg->msg_iov ) {
|
|
Mark Wielaard |
8b9a72 |
struct vki_iovec *iov = msg->msg_iov;
|
|
Mark Wielaard |
8b9a72 |
UInt i;
|
|
Mark Wielaard |
8b9a72 |
|
|
Mark Wielaard |
8b9a72 |
@@ -975,7 +977,8 @@ void msghdr_foreachfield (
|
|
Mark Wielaard |
8b9a72 |
}
|
|
Mark Wielaard |
8b9a72 |
}
|
|
Mark Wielaard |
8b9a72 |
|
|
Mark Wielaard |
8b9a72 |
- if ( msg->msg_control )
|
|
Mark Wielaard |
8b9a72 |
+ if ( ML_(safe_to_deref) (&msg->msg_control, sizeof (void *))
|
|
Mark Wielaard |
8b9a72 |
+ && msg->msg_control )
|
|
Mark Wielaard |
8b9a72 |
{
|
|
Mark Wielaard |
8b9a72 |
VG_(sprintf) ( fieldName, "(%s.msg_control)", name );
|
|
Mark Wielaard |
8b9a72 |
foreach_func ( tid, False, fieldName,
|