This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
[PATCH v2][BZ 16852] Do not clobber recvmmsg argument.
- From: OndÅej BÃlka <neleai at seznam dot cz>
- To: Andreas Schwab <schwab at linux-m68k dot org>
- Cc: libc-alpha at sourceware dot org
- Date: Mon, 28 Apr 2014 18:04:20 +0200
- Subject: [PATCH v2][BZ 16852] Do not clobber recvmmsg argument.
- Authentication-results: sourceware.org; auth=none
- References: <20140428152937 dot GA1736 at domone dot podge> <87mwf5zcl3 dot fsf at igel dot home>
On Mon, Apr 28, 2014 at 05:40:56PM +0200, Andreas Schwab wrote:
> OndÅej BÃlka <neleai@seznam.cz> writes:
>
> > + struct timespec dummy;
> > + memcpy (&dummy, tmo, sizeof (struct timespec));
>
> What's wrong with an assignment?
>
My first idea was memcpy, thanks.
> > if (SINGLE_THREAD_P)
> > return INLINE_SYSCALL (recvmmsg, 5, fd, vmessages, vlen, flags, tmo);
>
> You still pass a const where a non-const is expected.
>
fixed.
> Andreas.
>
Here is v2.
* sysdeps/unix/sysv/linux/recvmmsg.c (recvmmsg): Do not clobber
timeout argument.
diff --git a/sysdeps/unix/sysv/linux/recvmmsg.c b/sysdeps/unix/sysv/linux/recvmmsg.c
index 57ddf31..04a065f 100644
--- a/sysdeps/unix/sysv/linux/recvmmsg.c
+++ b/sysdeps/unix/sysv/linux/recvmmsg.c
@@ -35,14 +35,16 @@
#ifdef __NR_recvmmsg
int
recvmmsg (int fd, struct mmsghdr *vmessages, unsigned int vlen, int flags,
- const struct timespec *tmo)
+ const struct timespec *_tmo)
{
+ struct timespec tmo = *_tmo;
+
if (SINGLE_THREAD_P)
- return INLINE_SYSCALL (recvmmsg, 5, fd, vmessages, vlen, flags, tmo);
+ return INLINE_SYSCALL (recvmmsg, 5, fd, vmessages, vlen, flags, &tmo);
int oldtype = LIBC_CANCEL_ASYNC ();
- int result = INLINE_SYSCALL (recvmmsg, 5, fd, vmessages, vlen, flags, tmo);
+ int result = INLINE_SYSCALL (recvmmsg, 5, fd, vmessages, vlen, flags, &tmo);
LIBC_CANCEL_RESET (oldtype);
@@ -52,18 +54,20 @@ recvmmsg (int fd, struct mmsghdr *vmessages, unsigned int vlen, int flags,
# ifndef __ASSUME_RECVMMSG_SOCKETCALL
extern int __internal_recvmmsg (int fd, struct mmsghdr *vmessages,
unsigned int vlen, int flags,
- const struct timespec *tmo)
+ struct timespec *tmo)
attribute_hidden;
static int have_recvmmsg;
int
recvmmsg (int fd, struct mmsghdr *vmessages, unsigned int vlen, int flags,
- const struct timespec *tmo)
+ const struct timespec *_tmo)
{
+ struct timespec tmo = *_tmo;
+
if (__glibc_likely (have_recvmmsg >= 0))
{
- int ret = __internal_recvmmsg (fd, vmessages, vlen, flags, tmo);
+ int ret = __internal_recvmmsg (fd, vmessages, vlen, flags, &tmo);
/* The kernel returns -EINVAL for unknown socket operations.
We need to convert that error to an ENOSYS error. */
if (__builtin_expect (ret < 0, 0)