php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #58451 comparison with string literal results in unspecified behavior
Submitted: 2008-12-09 19:02 UTC Modified: 2008-12-10 05:17 UTC
From: crrodriguez at opensuse dot org Assigned:
Status: Closed Package: mogilefs (PECL)
PHP Version: 5_2 CVS-2008-12-09 (dev) OS: Irrelevant
Private report: No CVE-ID: None
 [2008-12-09 19:02 UTC] crrodriguez at opensuse dot org
Description:
------------
bug in: mogilefs.c lines 1307, 1356, 1405

comparison with string literal results in unspecified behavior

Reproduce code:
---------------
Compile with recent GCC versions.

Expected result:
----------------
No code with unspecified behaviuor.

Index: mogilefs.c
===================================================================
--- mogilefs.c.orig 2008-12-09 17:44:39.000000000 +0100
+++ mogilefs.c  2008-12-10 00:44:23.000000000 +0100
@@ -1304,7 +1304,7 @@ PHP_METHOD(MogileFs, createClass)
        RETURN_FALSE;
    }

-   if (domain == NULL || domain == "\0" || strlen(domain) == 0) {
+   if (domain == NULL || (strcmp(domain,"\0") == 0) || strlen(domain) == 0) {
        domain = mogilefs_sock->domain;
    }

@@ -1353,7 +1353,7 @@ PHP_METHOD(MogileFs, updateClass)
        RETURN_FALSE;
    }

-   if (domain == NULL || domain == "\0" || strlen(domain) == 0) {
+   if (domain == NULL || (strcmp(domain,"\0") == 0) || strlen(domain) == 0) {
        domain = mogilefs_sock->domain;
    }

@@ -1402,7 +1402,7 @@ PHP_METHOD(MogileFs, deleteClass)
        RETURN_FALSE;
    }

-   if (domain == NULL || domain == "\0" || strlen(domain) == 0) {
+   if (domain == NULL || (strcmp(domain,"\0") == 0) || strlen(domain) == 0) {
        domain = mogilefs_sock->domain;
    }


Actual result:
--------------
-----

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-12-10 05:17 UTC] lstrojny@php.net
This bug has been fixed in CVS.

In case this was a documentation problem, the fix will show up at the
end of next Sunday (CET) on pecl.php.net.

In case this was a pecl.php.net website problem, the change will show
up on the website in short time.
 
Thank you for the report, and for helping us make PECL better.


 
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Sat Feb 29 08:01:27 2020 UTC