Professional Web Applications Themes

#44594 [NEW]: unsigned long passed as $n_retries argument to imap_open() - PHP Bugs

From: net Operating system: Windows XP PHP version: 5.2CVS-2008-04-01 (snap) PHP Bug Type: IMAP related Bug description: unsigned long passed as $n_retries argument to imap_open() Description: ------------ When a negative integer is passed as the $n_retries argument to imap_open(), the number is passed as a signed long to the c-client function mail_parameters(), which is expecting an unsigned long to be passed on a SET_MAXLOGINTRIALS call. This results in $n_retries being set to a huge number. The problem is the the function php_imap_do_open() in ext/imap/php_imap.c. Below is a patch written by Andy Wharmby (CVS ID wharmby), it returns a warning if ...

  1. #1

    Default #44594 [NEW]: unsigned long passed as $n_retries argument to imap_open()

    From: net
    Operating system: Windows XP
    PHP version: 5.2CVS-2008-04-01 (snap)
    PHP Bug Type: IMAP related
    Bug description: unsigned long passed as $n_retries argument to imap_open()

    Description:
    ------------
    When a negative integer is passed as the $n_retries argument to
    imap_open(), the number is passed as a signed long to the c-client function
    mail_parameters(), which is expecting an unsigned long to be passed on a
    SET_MAXLOGINTRIALS call. This results in $n_retries being set to a huge
    number. The problem is the the function php_imap_do_open() in
    ext/imap/php_imap.c.
    Below is a patch written by Andy Wharmby (CVS ID wharmby), it returns a
    warning if $n_retries is less than 0:
    The code as it stands is:

    #ifdef SET_MAXLOGINTRIALS
    if (myargc == 5) {
    convert_to_long_ex(retries);
    mail_parameters(NIL, SET_MAXLOGINTRIALS, (void *) Z_LVAL_PP(retries));
    }
    #endif

    SOLUTION:


    #ifdef SET_MAXLOGINTRIALS
    if (myargc == 5) {
    convert_to_long_ex(retries);

    if (retries < 1) {
    php_error_docref(NULL TSRMLS_CC, E_WARNING ,"Retries cannot be less
    than 1");
    RETURN_FALSE;
    }

    mail_parameters(NIL, SET_MAXLOGINTRIALS, (void *) Z_LVAL_PP(retries));
    }
    #endif

    The doentation for the $n_retries argument also says that the number
    passed is "Number of maximum connect attempts" which is incorrect. There is
    always one attempt to connect, if that fails then $n_retries sets how many
    more attempts are made *after* the initial attempt.

    Reproduce code:
    ---------------
    <?php
    var_dump(imap_open($mailbox, $username, $password, null, -1));
    ?>


    --
    Edit bug report at http://bugs.php.net/?id=44594&edit=1
    --
    Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=44594&r=trysnapshot52
    Try a CVS snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=44594&r=trysnapshot53
    Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=44594&r=trysnapshot60
    Fixed in CVS: http://bugs.php.net/fix.php?id=44594&r=fixedcvs
    Fixed in release: http://bugs.php.net/fix.php?id=44594&r=alreadyfixed
    Need backtrace: http://bugs.php.net/fix.php?id=44594&r=needtrace
    Need Reproduce Script: http://bugs.php.net/fix.php?id=44594&r=needscript
    Try newer version: http://bugs.php.net/fix.php?id=44594&r=oldversion
    Not developer issue: http://bugs.php.net/fix.php?id=44594&r=support
    Expected behavior: http://bugs.php.net/fix.php?id=44594&r=notwrong
    Not enough info: http://bugs.php.net/fix.php?id=44594&r=notenoughinfo
    Submitted twice: http://bugs.php.net/fix.php?id=44594&r=submittedtwice
    register_globals: http://bugs.php.net/fix.php?id=44594&r=globals
    PHP 4 support discontinued: http://bugs.php.net/fix.php?id=44594&r=php4
    Daylight Savings: http://bugs.php.net/fix.php?id=44594&r=dst
    IIS Stability: http://bugs.php.net/fix.php?id=44594&r=isapi
    Install GNU Sed: http://bugs.php.net/fix.php?id=44594&r=gnused
    Floating point limitations: http://bugs.php.net/fix.php?id=44594&r=float
    No Zend Extensions: http://bugs.php.net/fix.php?id=44594&r=nozend
    MySQL Configuration Error: http://bugs.php.net/fix.php?id=44594&r=mysqlcfg

    jmessa@php.net Guest

  2. #2

    Default #44594 [Opn->Asn]: unsigned long passed as $n_retries argument to imap_open()

    ID: 44594
    Updated by: net
    Reported By: net
    -Status: Open
    +Status: Assigned
    Bug Type: IMAP related
    Operating System: Windows XP
    PHP Version: 5.2CVS-2008-04-01 (snap)
    -Assigned To:
    +Assigned To: iliaa


    Previous Comments:
    ------------------------------------------------------------------------

    [2008-04-01 15:54:57] net

    Description:
    ------------
    When a negative integer is passed as the $n_retries argument to
    imap_open(), the number is passed as a signed long to the c-client
    function mail_parameters(), which is expecting an unsigned long to be
    passed on a SET_MAXLOGINTRIALS call. This results in $n_retries being
    set to a huge number. The problem is the the function php_imap_do_open()
    in ext/imap/php_imap.c.
    Below is a patch written by Andy Wharmby (CVS ID wharmby), it returns a
    warning if $n_retries is less than 0:
    The code as it stands is:

    #ifdef SET_MAXLOGINTRIALS
    if (myargc == 5) {
    convert_to_long_ex(retries);
    mail_parameters(NIL, SET_MAXLOGINTRIALS, (void *)
    Z_LVAL_PP(retries));
    }
    #endif

    SOLUTION:


    #ifdef SET_MAXLOGINTRIALS
    if (myargc == 5) {
    convert_to_long_ex(retries);

    if (retries < 1) {
    php_error_docref(NULL TSRMLS_CC, E_WARNING ,"Retries cannot be less
    than 1");
    RETURN_FALSE;
    }

    mail_parameters(NIL, SET_MAXLOGINTRIALS, (void *)
    Z_LVAL_PP(retries));
    }
    #endif

    The doentation for the $n_retries argument also says that the number
    passed is "Number of maximum connect attempts" which is incorrect. There
    is always one attempt to connect, if that fails then $n_retries sets how
    many more attempts are made *after* the initial attempt.

    Reproduce code:
    ---------------
    <?php
    var_dump(imap_open($mailbox, $username, $password, null, -1));
    ?>



    ------------------------------------------------------------------------


    --
    Edit this bug report at http://bugs.php.net/?id=44594&edit=1

    iliaa@php.net Guest

  3. #3

    Default #44594 [Asn->Csd]: unsigned long passed as $n_retries argument to imap_open()

    ID: 44594
    Updated by: net
    Reported By: net
    -Status: Assigned
    +Status: Closed
    Bug Type: IMAP related
    Operating System: Windows XP
    PHP Version: 5.2CVS-2008-04-01 (snap)
    Assigned To: iliaa
    New Comment:

    This bug has been fixed in CVS.

    Snapshots of the sources are packaged every three hours; this change
    will be in the next snapshot. You can grab the snapshot at
    http://snaps.php.net/.

    Thank you for the report, and for helping us make PHP better.




    Previous Comments:
    ------------------------------------------------------------------------

    [2008-04-01 15:54:57] net

    Description:
    ------------
    When a negative integer is passed as the $n_retries argument to
    imap_open(), the number is passed as a signed long to the c-client
    function mail_parameters(), which is expecting an unsigned long to be
    passed on a SET_MAXLOGINTRIALS call. This results in $n_retries being
    set to a huge number. The problem is the the function php_imap_do_open()
    in ext/imap/php_imap.c.
    Below is a patch written by Andy Wharmby (CVS ID wharmby), it returns a
    warning if $n_retries is less than 0:
    The code as it stands is:

    #ifdef SET_MAXLOGINTRIALS
    if (myargc == 5) {
    convert_to_long_ex(retries);
    mail_parameters(NIL, SET_MAXLOGINTRIALS, (void *)
    Z_LVAL_PP(retries));
    }
    #endif

    SOLUTION:


    #ifdef SET_MAXLOGINTRIALS
    if (myargc == 5) {
    convert_to_long_ex(retries);

    if (retries < 1) {
    php_error_docref(NULL TSRMLS_CC, E_WARNING ,"Retries cannot be less
    than 1");
    RETURN_FALSE;
    }

    mail_parameters(NIL, SET_MAXLOGINTRIALS, (void *)
    Z_LVAL_PP(retries));
    }
    #endif

    The doentation for the $n_retries argument also says that the number
    passed is "Number of maximum connect attempts" which is incorrect. There
    is always one attempt to connect, if that fails then $n_retries sets how
    many more attempts are made *after* the initial attempt.

    Reproduce code:
    ---------------
    <?php
    var_dump(imap_open($mailbox, $username, $password, null, -1));
    ?>



    ------------------------------------------------------------------------


    --
    Edit this bug report at http://bugs.php.net/?id=44594&edit=1

    iliaa@php.net Guest

Similar Threads

  1. Databinder.Eval passed as argument is choking
    By TJ in forum ASP.NET Data Grid Control
    Replies: 3
    Last Post: October 10th, 06:48 PM
  2. Using $_ in a function if no argument is passed
    By Jupiterhost.Net in forum PERL Beginners
    Replies: 13
    Last Post: April 4th, 09:56 PM
  3. Replies: 0
    Last Post: July 18th, 07:23 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139