{"thread":{"id":"31467","subject":"RE: [PATCH v3 1/4] poll() exits too early with EFAULT if 1st arg is NULL","startedAt":"2012-09-07T12:52:48Z","lastAt":"2012-09-13T07:15:44Z","messageCount":3,"participants":["Joachim Schmitz"],"isPatch":true,"patchVersion":3,"patchTotal":4},"messages":[{"id":"198517","messageId":"003a01cd8cf7$af821100$0e863300$@schmitz-digital.de","threadId":"31467","inReplyTo":null,"subject":"RE: [PATCH v3 1/4] poll() exits too early with EFAULT if 1st arg is NULL","fromName":"Joachim Schmitz","fromEmail":"jojo@schmitz-digital.de","sentAt":"2012-09-07T12:52:48Z","receivedAt":"2012-09-07T12:52:48Z","isPatch":true,"sender":{"key":"jojo@schmitz-digital.de","avatar":"https://avatars.githubusercontent.com/u/1786669?v=4"},"body":"If poll() is used as a milli-second sleep, like in help.c, by passing a NULL\nin the 1st and a 0 in the 2nd arg, it exits with EFAULT.\n\nAs per Paolo Bonzini, the original author, this is a bug and to be fixed like\nin this commit, which is not to exit if the 2nd arg is 0.\n\nSigned-off-by: Joachim Schmitz <jojo@schmitz-digital.de>\n---\n compat/win32/poll.c | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/compat/win32/poll.c b/compat/win32/poll.c\nindex 403eaa7..9e7a25c 100644\n--- a/compat/win32/poll.c\n+++ b/compat/win32/poll.c\n@@ -349,7 +349,7 @@ poll (struct pollfd *pfd, nfds_t nfd, int timeout)\n \n   /* EFAULT is not necessary to implement, but let's do it in the\n      simplest case. */\n-  if (!pfd)\n+  if (!pfd && nfd)\n     {\n       errno = EFAULT;\n       return -1;\n-- \n1.7.12\n"},{"id":"198769","messageId":"k2n79l$s9e$1@ger.gmane.org","threadId":"31467","inReplyTo":"003a01cd8cf7$af821100$0e863300$@schmitz-digital.de","subject":"Re: [PATCH v3 1/4] poll() exits too early with EFAULT if 1st arg is NULL","fromName":"Joachim Schmitz","fromEmail":"jojo@schmitz-digital.de","sentAt":"2012-09-11T11:28:47Z","receivedAt":"2012-09-11T11:28:47Z","isPatch":true,"sender":{"key":"jojo@schmitz-digital.de","avatar":"https://avatars.githubusercontent.com/u/1786669?v=4"},"body":"Joachim Schmitz wrote:\n> If poll() is used as a milli-second sleep, like in help.c, by passing\n> a NULL in the 1st and a 0 in the 2nd arg, it exits with EFAULT.\n>\n> As per Paolo Bonzini, the original author, this is a bug and to be\n> fixed like in this commit, which is not to exit if the 2nd arg is 0.\n>\n> Signed-off-by: Joachim Schmitz <jojo@schmitz-digital.de>\n> ---\n> compat/win32/poll.c | 2 +-\n> 1 file changed, 1 insertion(+), 1 deletion(-)\n>\n> diff --git a/compat/win32/poll.c b/compat/win32/poll.c\n> index 403eaa7..9e7a25c 100644\n> --- a/compat/win32/poll.c\n> +++ b/compat/win32/poll.c\n> @@ -349,7 +349,7 @@ poll (struct pollfd *pfd, nfds_t nfd, int timeout)\n>\n>   /* EFAULT is not necessary to implement, but let's do it in the\n>      simplest case. */\n> -  if (!pfd)\n> +  if (!pfd && nfd)\n>     {\n>       errno = EFAULT;\n>       return -1;\n\nActually this one is not needed for win32 (nor does win32 suffer from a \nsimilar bug), so should probably better get added after patch 2/2 (or as \npart of it), the move to compat/poll/.\n\nBye, Jojo\n"},{"id":"198903","messageId":"k2s177$l37$1@ger.gmane.org","threadId":"31467","inReplyTo":"k2n79l$s9e$1@ger.gmane.org","subject":"Re: [PATCH v3 1/4] poll() exits too early with EFAULT if 1st arg is NULL","fromName":"Joachim Schmitz","fromEmail":"jojo@schmitz-digital.de","sentAt":"2012-09-13T07:15:44Z","receivedAt":"2012-09-13T07:15:44Z","isPatch":true,"sender":{"key":"jojo@schmitz-digital.de","avatar":"https://avatars.githubusercontent.com/u/1786669?v=4"},"body":"Joachim Schmitz wrote:\n> Joachim Schmitz wrote:\n>> If poll() is used as a milli-second sleep, like in help.c, by passing\n>> a NULL in the 1st and a 0 in the 2nd arg, it exits with EFAULT.\n>> \n>> As per Paolo Bonzini, the original author, this is a bug and to be\n>> fixed like in this commit, which is not to exit if the 2nd arg is 0.\n>> \n>> Signed-off-by: Joachim Schmitz <jojo@schmitz-digital.de>\n>> ---\n>> compat/win32/poll.c | 2 +-\n>> 1 file changed, 1 insertion(+), 1 deletion(-)\n>> \n>> diff --git a/compat/win32/poll.c b/compat/win32/poll.c\n>> index 403eaa7..9e7a25c 100644\n>> --- a/compat/win32/poll.c\n>> +++ b/compat/win32/poll.c\n>> @@ -349,7 +349,7 @@ poll (struct pollfd *pfd, nfds_t nfd, int\n>> timeout) \n>> \n>>   /* EFAULT is not necessary to implement, but let's do it in the\n>>      simplest case. */\n>> -  if (!pfd)\n>> +  if (!pfd && nfd)\n>>     {\n>>       errno = EFAULT;\n>>       return -1;\n> \n> Actually this one is not needed for win32 (nor does win32 suffer from\n> a similar bug), so should probably better get added after patch 2/2\n> (or as part of it), the move to compat/poll/.\n\nIt just got added that was to gnulib, with a commit message of:\n\ndon't exit early if NULL is the 1st arg to poll(),\nbut nfd is 0.  In that case poll should behave like select.\n\nBye, Jojo\n"}]}