php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #6203 imap_search() munges variables
Submitted: 2000-08-16 17:47 UTC Modified: 2000-08-18 12:36 UTC
From: max at the-triumvirate dot net Assigned:
Status: Closed Package: IMAP related
PHP Version: 4.0.1pl2 OS: RH6.2
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: max at the-triumvirate dot net
New email:
PHP Version: OS:

 

 [2000-08-16 17:47 UTC] max at the-triumvirate dot net
After running the imap_search() function the variable in which the IMAP search query was help gets changed such that any subsequent calls to imap_search() fail. The following code:

#########CODE BEGIN###########
<?php

$user  = '****';
$pass  = '****';
$folders = array("INBOX", "mail/sent-mail");

$query = 'SUBJECT "babble" BODY "babble"';

echo '$query before imap_open() [', $query, "]<br>\n";
$stream = imap_open("{host:143}", $user, $pass);
echo '$query after imap_open() [', $query, "]<br>\n";

for ($i = 0; $i < count($folders); $i++) { 

  echo '$query before imap_open() [', $query, "]<br>\n";
  $stream = @imap_open("{host:143}" . $folders[$i],
                        $user, $pass, OP_READONLY);
  echo '$query after imap_open() [', $query, "]<br>\n";

  if ($stream) {

    echo '$query before imap_search() [', $query, "]<br>\n";
    $results = imap_search($stream, $query, SE_UID);
    echo '$query after imap_search() [', $query, "]<br>\n";

    if (is_array($results)) {
      echo "found ", count($results), " messages<br><br>\n";
    } 
    imap_close($stream);
  } 
} 
?>
#########CODE END###########

yeilds the following results:

$query before imap_open() [SUBJECT "babble" BODY "babble"]
$query after imap_open() [SUBJECT "babble" BODY "babble"]
$query before imap_open() [SUBJECT "babble" BODY "babble"]
$query after imap_open() [SUBJECT "babble" BODY "babble"]
$query before imap_search() [SUBJECT "babble" BODY "babble"]
$query after imap_search() [SUBJECT"babble BODY"babble]
$query before imap_open() [SUBJECT"babble BODY"babble]
$query after imap_open() [SUBJECT"babble BODY"babble]
$query before imap_search() [SUBJECT"babble BODY"babble]
$query after imap_search() [SUBJECT"babble BODY"babble]
$query before imap_open() [SUBJECT"babble BODY"babble]
$query after imap_open() [SUBJECT"babble BODY"babble]
$query before imap_search() [SUBJECT"babble BODY"babble]
$query after imap_search() [SUBJECT"babble BODY"babble]


Another test I ran was to "backup" $query:

$backup = $query;

Even if $backup is used to run the imap_search() both $query and $backup are munged.

Test Platforms:
  linux rh6.2 2.2.16 (i386)
  solaris 2.6 (sun ultra 5)

  apache 1.3.12
  php 4.0.1pl2
    +imap 4.7c
    +mysql 3.22.32
    +openldap 1.2.11
    +gd 1.8.2
    +gdbm 1.8.0
    +gettext 0.10.35
    +zlib 1.1.3

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2000-08-17 12:06 UTC] chagenbu@php.net
I just added a cpystr() around the place where the query string gets passed to mail_criteria, and that seemed to fix the problem - give latest cvs a whirl.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 26 00:01:30 2024 UTC