@@ -1256,7 +1256,7 @@ PHP_FUNCTION(imap_body)
1256
1256
zval * streamind ;
1257
1257
zend_long msgno , flags = 0 ;
1258
1258
pils * imap_le_struct ;
1259
- int msgindex ;
1259
+ unsigned long msgindex ;
1260
1260
char * body ;
1261
1261
unsigned long body_len = 0 ;
1262
1262
@@ -1283,11 +1283,14 @@ PHP_FUNCTION(imap_body)
1283
1283
IMAP server, then that's the price we pay for making
1284
1284
sure we don't crash. */
1285
1285
msgindex = mail_msgno (imap_le_struct -> imap_stream , msgno );
1286
+ if (msgindex == 0 ) {
1287
+ php_error_docref (NULL , E_WARNING , "UID does not exist" );
1288
+ RETURN_FALSE ;
1289
+ }
1286
1290
} else {
1287
- msgindex = msgno ;
1291
+ msgindex = ( unsigned long ) msgno ;
1288
1292
}
1289
1293
1290
- // TODO int overflow as can be seen in imap_body.phpt will result in 999 => <0 trigerring a ValueError
1291
1294
PHP_IMAP_CHECK_MSGNO (msgindex , 2 );
1292
1295
1293
1296
/* TODO Shouldn't this pass msgindex??? */
@@ -1901,6 +1904,10 @@ PHP_FUNCTION(imap_fetchstructure)
1901
1904
IMAP server, then that's the price we pay for making
1902
1905
sure we don't crash. */
1903
1906
msgindex = mail_msgno (imap_le_struct -> imap_stream , msgno );
1907
+ if (msgindex == 0 ) {
1908
+ php_error_docref (NULL , E_WARNING , "UID does not exist" );
1909
+ RETURN_FALSE ;
1910
+ }
1904
1911
} else {
1905
1912
msgindex = msgno ;
1906
1913
}
@@ -2779,6 +2786,10 @@ PHP_FUNCTION(imap_fetchheader)
2779
2786
IMAP server, then that's the price we pay for making sure
2780
2787
we don't crash. */
2781
2788
msgindex = mail_msgno (imap_le_struct -> imap_stream , msgno );
2789
+ if (msgindex == 0 ) {
2790
+ php_error_docref (NULL , E_WARNING , "UID does not exist" );
2791
+ RETURN_FALSE ;
2792
+ }
2782
2793
} else {
2783
2794
msgindex = msgno ;
2784
2795
}
0 commit comments