From 297178cf3526b6ad772bb37c17afb4a43867e2be Mon Sep 17 00:00:00 2001 From: Ilia Alshanetsky Date: Thu, 8 Dec 2005 03:26:16 +0000 Subject: [PATCH] MFH: Fixed bug #35594 (Multiple calls to getopt() may result in a crash). --- NEWS | 2 ++ ext/standard/basic_functions.c | 3 +++ 2 files changed, 5 insertions(+) diff --git a/NEWS b/NEWS index 5dce0d5987..29c1c93c81 100644 --- a/NEWS +++ b/NEWS @@ -3,6 +3,8 @@ PHP 4 NEWS ?? ??? 2005, Version 4.4.2 - Prevent header injection by limiting each header to a single line. (Ilia) - Fixed possible XSS inside error reporting functionality. (Ilia) +- Fixed bug #35594 (Multiple calls to getopt() may result in a crash). + (rabbitt at gmail dot com, Ilia) - Fixed bug #35536 (mysql_field_type() doesn't handle NEWDECIMAL). (Tony) - Fixed bug #35410 (wddx_deserialize() doesn't handle large ints as keys properly). (Ilia) diff --git a/ext/standard/basic_functions.c b/ext/standard/basic_functions.c index bf9af8f580..09badbc31f 100644 --- a/ext/standard/basic_functions.c +++ b/ext/standard/basic_functions.c @@ -1595,6 +1595,9 @@ PHP_FUNCTION(getopt) /* Disable getopt()'s error messages. */ opterr = 0; + /* Force reinitialization of getopt() (via optind reset) on every call. */ + optind = 0; + /* Invoke getopt(3) on the argument array. */ #ifdef HARTMUT_0 while ((o = getopt_long(argc, argv, options, longopts, &longindex)) != -1) { -- 2.50.1