Changeset d2993ee in github
- Timestamp:
- Oct 30, 2008 5:17:36 AM (5 years ago)
- Branches:
- master, HEAD, courier-fix, dev-browser-capabilities, pdo, release-0.6, release-0.7, release-0.8
- Children:
- d0d94ca
- Parents:
- d245963
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
CHANGELOG
r8498dce rd2993ee 5 5 ---------- 6 6 - Fix problem with numeric folder names (#1485527) 7 - Added BYE response simple support to prevent from endless loops in imap.inc (#1483956) 7 8 8 9 2008/10/27 (alec) -
index.php
rc9ca6ad rd2993ee 101 101 } 102 102 else { 103 $OUTPUT->show_message($IMAP->error_code == -1 ? ' imaperror' : 'loginfailed', 'warning');103 $OUTPUT->show_message($IMAP->error_code == -1 ? 'loginfailed' : 'imaperror', 'warning'); 104 104 $RCMAIL->kill_session(); 105 105 } -
program/lib/imap.inc
r7ae46f2 rd2993ee 69 69 - added iil_PutLineC() 70 70 - fixed iil_C_Sort() to support very long and/or divided responses 71 - added BYE response simple support for endless loop prevention 72 - added 3rd argument in iil_StartsWith* functions 71 73 72 74 ********************************************************/ … … 287 289 } else if (strcasecmp($a[1], 'BAD') == 0) { 288 290 return -2; 291 } else if (strcasecmp($a[1], 'BYE') == 0) { 292 return -3; 289 293 } 290 294 } 291 return - 3;295 return -4; 292 296 } 293 297 294 298 // check if $string starts with $match 295 function iil_StartsWith($string, $match ) {299 function iil_StartsWith($string, $match, $bye=false) { 296 300 $len = strlen($match); 297 301 if ($len == 0) { … … 301 305 return true; 302 306 } 307 if ($bye && strncmp($string, '* BYE ', 6) == 0) { 308 return true; 309 } 303 310 return false; 304 311 } 305 312 306 function iil_StartsWithI($string, $match ) {313 function iil_StartsWithI($string, $match, $bye=false) { 307 314 $len = strlen($match); 308 315 if ($len == 0) { … … 310 317 } 311 318 if (strncasecmp($string, $match, $len) == 0) { 319 return true; 320 } 321 if ($bye && strncmp($string, '* BYE ', 6) == 0) { 312 322 return true; 313 323 } … … 382 392 383 393 // process result 384 if (iil_ParseResult($line) == 0) { 394 $result = iil_ParseResult($line); 395 if ($result == 0) { 385 396 $conn->error .= ''; 386 397 $conn->errorNum = 0; 387 398 return $conn->fp; 388 399 } 400 401 if ($result == -3) fclose($conn->fp); // BYE response 402 389 403 $conn->error .= 'Authentication for ' . $user . ' failed (AUTH): "'; 390 404 $conn->error .= htmlspecialchars($line) . '"'; 391 $conn->errorNum = -2; 392 return false; 405 $conn->errorNum = $result; 406 407 return $result; 393 408 } 394 409 … … 402 417 break; 403 418 } 404 } while (!iil_StartsWith($line, "a001 ")); 405 $a = explode(' ', $line); 406 if (strcmp($a[1], 'OK') == 0) { 407 $result = $conn->fp; 419 } while (!iil_StartsWith($line, 'a001 ', true)); 420 421 // process result 422 $result = iil_ParseResult($line); 423 424 if ($result == 0) { 408 425 $conn->error .= ''; 409 426 $conn->errorNum = 0; 410 return $ result;427 return $conn->fp; 411 428 } 412 $result = false; 429 413 430 fclose($conn->fp); 414 431 415 432 $conn->error .= 'Authentication for ' . $user . ' failed (LOGIN): "'; 416 433 $conn->error .= htmlspecialchars($line)."\""; 417 $conn->errorNum = -2;434 $conn->errorNum = $result; 418 435 419 436 return $result; … … 473 490 $data = iil_ParseNamespace2(substr($line,11), $i, 0, 0); 474 491 } 475 } while (!iil_StartsWith($line, "ns1"));492 } while (!iil_StartsWith($line, 'ns1', true)); 476 493 477 494 if (!is_array($data)) { … … 504 521 $iil_error = ''; 505 522 $iil_errornum = 0; 506 507 //strip slashes508 // $user = stripslashes($user);509 // $password = stripslashes($password);510 523 511 524 //set auth method … … 544 557 //check input 545 558 if (empty($host)) { 546 $iil_error .= "Invalid host\n"; 559 $iil_error = "Empty host"; 560 $iil_errornum = -1; 561 return false; 547 562 } 548 563 if (empty($user)) { 549 $iil_error .= "Invalid user\n"; 564 $iil_error = "Empty user"; 565 $iil_errornum = -1; 566 return false; 550 567 } 551 568 if (empty($password)) { 552 $iil_error .= "Invalid password\n"; 553 } 554 if (!empty($iil_error)) { 569 $iil_error = "Empty password"; 570 $iil_errornum = -1; 555 571 return false; 556 572 } … … 607 623 //got a challenge string, try CRAM-5 608 624 $result = iil_C_Authenticate($conn, $user, $password, substr($line,2)); 609 625 626 // stop if server sent BYE response 627 if($result == -3) { 628 $iil_error = $conn->error; 629 $iil_errornum = $conn->errorNum; 630 return false; 631 } 610 632 $conn->message .= "Tried CRAM-MD5: $result \n"; 611 633 } else { … … 618 640 //do plain text auth 619 641 $result = iil_C_Login($conn, $user, $password); 620 $conn->message .="Tried PLAIN: $result \n";642 $conn->message .= "Tried PLAIN: $result \n"; 621 643 } 622 644 623 645 $conn->message .= $auth; 624 646 625 if ( $result) {647 if (!is_int($result)) { 626 648 iil_C_Namespace($conn); 627 649 return $conn; … … 753 775 if (($a[0] == '*') && (strcasecmp($a[2], 'RECENT') == 0)) { 754 776 $result = (int) $a[1]; 755 }756 } while (!iil_StartsWith($a[0], 'a002' ));777 } 778 } while (!iil_StartsWith($a[0], 'a002', true)); 757 779 758 780 iil_PutLine($fp, "a003 LOGOUT"); … … 791 813 $conn->permanentflags = explode(' ', $match[1]); 792 814 } 793 } while (!iil_StartsWith($line, 'sel1' ));815 } while (!iil_StartsWith($line, 'sel1', true)); 794 816 795 817 $a = explode(' ', $line); … … 839 861 function iil_StrToTime($str) { 840 862 $IMAP_MONTHS = $GLOBALS['IMAP_MONTHS']; 841 $IMAP_SERVER_TZ = $GLOBALS['IMAP_SERVER_T R'];863 $IMAP_SERVER_TZ = $GLOBALS['IMAP_SERVER_TZ']; 842 864 843 865 if ($str) { … … 918 940 $data .= $line; 919 941 } 920 } while ( $line[0]!='s');942 } while (!iil_StartsWith($line, 's ', true)); 921 943 922 944 if (empty($data)) { … … 1040 1062 } 1041 1063 */ 1042 } while (!iil_StartsWith($line, $key ));1064 } while (!iil_StartsWith($line, $key, true)); 1043 1065 1044 1066 }else if ($mode == 6) { … … 1071 1093 $a = explode(' ', $line); 1072 1094 } 1073 } while (!iil_StartsWith($a[0], $key ));1095 } while (!iil_StartsWith($a[0], $key, true)); 1074 1096 } else { 1075 1097 if ($mode >= 3) { … … 1113 1135 } 1114 1136 } 1115 } while (!iil_StartsWith($line, $key ));1137 } while (!iil_StartsWith($line, $key, true)); 1116 1138 } 1117 1139 … … 1952 1974 $c++; 1953 1975 } 1954 } while (!iil_StartsWith($line, 'exp1' ));1976 } while (!iil_StartsWith($line, 'exp1', true)); 1955 1977 1956 1978 if (iil_ParseResult($line) == 0) { … … 1984 2006 $c++; 1985 2007 } 1986 } while (!iil_StartsWith($line, 'flg' ));2008 } while (!iil_StartsWith($line, 'flg', true)); 1987 2009 1988 2010 if (iil_ParseResult($line) == 0) { … … 2094 2116 $messages = explode(' ', $str); 2095 2117 } 2096 } while (!iil_StartsWith($line, 'srch1' ));2118 } while (!iil_StartsWith($line, 'srch1', true)); 2097 2119 2098 2120 $result_code = iil_ParseResult($line); … … 2152 2174 } 2153 2175 } 2154 } while (!iil_StartsWith($line, 'ghd' ));2176 } while (!iil_StartsWith($line, 'ghd', true)); 2155 2177 2156 2178 if (strlen($delimiter)>0) { … … 2167 2189 $data = iil_ParseNamespace2(substr($line,11), $i, 0, 0); 2168 2190 } 2169 } while (!iil_StartsWith($line, 'ns1' ));2191 } while (!iil_StartsWith($line, 'ns1', true)); 2170 2192 2171 2193 if (!is_array($data)) { … … 2235 2257 $i++; 2236 2258 } 2237 } while (!iil_StartsWith($line, 'lmb' ));2259 } while (!iil_StartsWith($line, 'lmb', true)); 2238 2260 2239 2261 if (is_array($folders)) { … … 2304 2326 $i++; 2305 2327 } 2306 } while (!iil_StartsWith($line, 'lsb' ));2328 } while (!iil_StartsWith($line, 'lsb', true)); 2307 2329 2308 2330 if (is_array($folders)) { … … 2360 2382 $a = explode(' ', $line); 2361 2383 if (($line[0] == '*') && ($a[2] == 'FETCH') 2362 && ($line[strlen($line)-1] != ')')) {2384 && ($line[strlen($line)-1] != ')')) { 2363 2385 $line=iil_ReadLine($fp, 300); 2364 2386 while (trim($line) != ')') { … … 2367 2389 } 2368 2390 } 2369 } while (strcmp($a[0], $key) != 0 );2391 } while (strcmp($a[0], $key) != 0 && ($a[0] != '*' || $a[1] != 'BYE')); 2370 2392 } 2371 2393 … … 2403 2425 } while ($a[2] != 'FETCH'); 2404 2426 $len = strlen($line); 2405 2406 if ($line[$len-1] == ')') { 2427 2428 // handle empty "* X FETCH ()" response 2429 if ($line[$len-1] == ')' && $line[$len-2] != '(') { 2407 2430 // one line response, get everything between first and last quotes 2408 2431 if (substr($line, -4, 3) == 'NIL') { … … 2459 2482 do { 2460 2483 $line = iil_ReadLine($fp, 1024); 2461 } while (!iil_StartsWith($line, $key ));2484 } while (!iil_StartsWith($line, $key, true)); 2462 2485 2463 2486 if ($mode == 3 && $file) { … … 2672 2695 $quota_line = $line; 2673 2696 } 2674 } while (!iil_StartsWith($line, 'QUOT1' ));2697 } while (!iil_StartsWith($line, 'QUOT1', true)); 2675 2698 } 2676 2699
Note: See TracChangeset
for help on using the changeset viewer.
