This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH v2][BZ 16852] Do not clobber recvmmsg argument.


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)


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]