Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:43058 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 69992 invoked from network); 15 Feb 2009 21:47:59 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 15 Feb 2009 21:47:59 -0000 Authentication-Results: pb1.pair.com smtp.mail=greg@chiaraquartet.net; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=greg@chiaraquartet.net; sender-id=unknown Received-SPF: error (pb1.pair.com: domain chiaraquartet.net from 209.85.198.228 cause and error) X-PHP-List-Original-Sender: greg@chiaraquartet.net X-Host-Fingerprint: 209.85.198.228 rv-out-0506.google.com Received: from [209.85.198.228] ([209.85.198.228:56758] helo=rv-out-0506.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id C3/FA-08422-D8D88994 for ; Sun, 15 Feb 2009 16:47:58 -0500 Received: by rv-out-0506.google.com with SMTP id g9so896239rvb.7 for ; Sun, 15 Feb 2009 13:47:55 -0800 (PST) Received: by 10.142.135.13 with SMTP id i13mr1875484wfd.217.1234734475243; Sun, 15 Feb 2009 13:47:55 -0800 (PST) Received: from ?192.168.223.130? ([76.84.30.125]) by mx.google.com with ESMTPS id 31sm7885155wff.36.2009.02.15.13.47.53 (version=TLSv1/SSLv3 cipher=RC4-MD5); Sun, 15 Feb 2009 13:47:54 -0800 (PST) Message-ID: <49925D0F.7090601@chiaraquartet.net> Date: Tue, 10 Feb 2009 23:07:27 -0600 User-Agent: Thunderbird 2.0.0.19 (X11/20090105) MIME-Version: 1.0 To: internals@lists.php.net Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: int/long conflict in spl? From: greg@chiaraquartet.net (Greg Beaver) Hi, While tracking down a problem in one of phar's tests, I found what might be a problem in RecursiveDirectoryIterator's handling of flags. Here is a crude patch demonstrating the issue, and wondering if this is something to be concerned about. Basically, we're mixing long and int, which could lead to truncation in unpredictable ways. Greg Index: spl_directory.c =================================================================== RCS file: /repository/php-src/ext/spl/spl_directory.c,v retrieving revision 1.45.2.27.2.23.2.40 diff -u -r1.45.2.27.2.23.2.40 spl_directory.c --- spl_directory.c 31 Dec 2008 11:15:43 -0000 1.45.2.27.2.23.2.40 +++ spl_directory.c 15 Feb 2009 21:45:00 -0000 @@ -215,7 +215,7 @@ /* open a directory resource */ static void spl_filesystem_dir_open(spl_filesystem_object* intern, char *path TSRMLS_DC) { - int skip_dots = intern->flags & SPL_FILE_DIR_SKIPDOTS; + int skip_dots = (intern->flags & SPL_FILE_DIR_SKIPDOTS) ? 1 : 0; intern->type = SPL_FS_DIR; intern->_path_len = strlen(path); @@ -314,7 +314,7 @@ case SPL_FS_DIR: spl_filesystem_dir_open(intern, source->_path TSRMLS_CC); /* read until we hit the position in which we were before */ - skip_dots = source->flags & SPL_FILE_DIR_SKIPDOTS; + skip_dots = (source->flags & SPL_FILE_DIR_SKIPDOTS) ? 1 : 0; for(index = 0; index < source->u.dir.index; ++index) { do { spl_filesystem_dir_read(intern TSRMLS_CC); @@ -600,7 +600,7 @@ #define DIT_CTOR_FLAGS 0x00000001 #define DIT_CTOR_GLOB 0x00000002 -void spl_filesystem_object_construct(INTERNAL_FUNCTION_PARAMETERS, int ctor_flags) /* {{{ */ +void spl_filesystem_object_construct(INTERNAL_FUNCTION_PARAMETERS, long ctor_flags) /* {{{ */ { spl_filesystem_object *intern; char *path; @@ -698,7 +698,7 @@ SPL_METHOD(DirectoryIterator, next) { spl_filesystem_object *intern = (spl_filesystem_object*)zend_object_store_get_object(getThis() TSRMLS_CC); - int skip_dots = intern->flags & SPL_FILE_DIR_SKIPDOTS; + int skip_dots = (intern->flags & SPL_FILE_DIR_SKIPDOTS) ? 1 : 0; intern->u.dir.index++; do {