]> Pileus Git - ~andy/git/commitdiff
poll() exits too early with EFAULT if 1st arg is NULL
authorJoachim Schmitz <jojo@schmitz-digital.de>
Mon, 17 Sep 2012 21:23:17 +0000 (23:23 +0200)
committerJunio C Hamano <gitster@pobox.com>
Mon, 17 Sep 2012 22:43:44 +0000 (15:43 -0700)
If poll() is used as a milli-second sleep, like in help.c, by passing a NULL
in the 1st and a 0 in the 2nd arg, it exits with EFAULT.

As per Paolo Bonzini, the original author, this is a bug and to be fixed
Like in this commit, which is not to exit if the 2nd arg is 0. It got fixed
In gnulib in the same manner the other day.

Signed-off-by: Joachim Schmitz <jojo@schmitz-digital.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
compat/poll/poll.c

index 49541f19cd1fa21de071ef0df214117bb4908d41..e4b8319fb7335bfc31eb3e1e96605f077e2b568d 100644 (file)
@@ -353,7 +353,7 @@ poll (struct pollfd *pfd, nfds_t nfd, int timeout)
 
   /* EFAULT is not necessary to implement, but let's do it in the
      simplest case. */
-  if (!pfd)
+  if (!pfd && nfd)
     {
       errno = EFAULT;
       return -1;