@@ -1208,22 +1208,29 @@ PHP_FUNCTION(imap_headers)
1208
1208
Read the message body */
1209
1209
PHP_FUNCTION (imap_body )
1210
1210
{
1211
- zval * * streamind , * * msgno , * * flags ;
1211
+ zval * * streamind , * * msgno , * * pflags ;
1212
1212
pils * imap_le_struct ;
1213
1213
int msgindex , myargc = ZEND_NUM_ARGS ();
1214
+ long flags = 0L ;
1214
1215
1215
- if (myargc < 2 || myargc > 3 || zend_get_parameters_ex (myargc , & streamind , & msgno , & flags ) == FAILURE ) {
1216
+ if (myargc < 2 || myargc > 3 || zend_get_parameters_ex (myargc , & streamind , & msgno , & pflags ) == FAILURE ) {
1216
1217
ZEND_WRONG_PARAM_COUNT ();
1217
1218
}
1218
1219
1220
+
1219
1221
ZEND_FETCH_RESOURCE (imap_le_struct , pils * , streamind , -1 , "imap" , le_imap );
1220
1222
1221
1223
convert_to_long_ex (msgno );
1222
1224
if (myargc == 3 ) {
1223
- convert_to_long_ex (flags );
1225
+ convert_to_long_ex (pflags );
1226
+ flags = Z_LVAL_PP (pflags );
1227
+ if (flags && ((flags & ~(FT_UID |FT_PEEK |FT_INTERNAL )) != 0 )) {
1228
+ php_error_docref (NULL TSRMLS_CC , E_WARNING , "invalid value for the options parameter" );
1229
+ RETURN_FALSE ;
1230
+ }
1224
1231
}
1225
1232
1226
- if ((myargc == 3 ) && (Z_LVAL_PP ( flags ) & FT_UID )) {
1233
+ if ((myargc == 3 ) && (flags & FT_UID )) {
1227
1234
/* This should be cached; if it causes an extra RTT to the
1228
1235
IMAP server, then that's the price we pay for making
1229
1236
sure we don't crash. */
@@ -1236,7 +1243,7 @@ PHP_FUNCTION(imap_body)
1236
1243
RETURN_FALSE ;
1237
1244
}
1238
1245
1239
- RETVAL_STRING (mail_fetchtext_full (imap_le_struct -> imap_stream , Z_LVAL_PP (msgno ), NIL , myargc == 3 ? Z_LVAL_PP (flags ) : NIL ), 1 );
1246
+ RETVAL_STRING (mail_fetchtext_full (imap_le_struct -> imap_stream , Z_LVAL_PP (msgno ), NIL , myargc == 3 ? Z_LVAL_PP (pflags ) : NIL ), 1 );
1240
1247
}
1241
1248
/* }}} */
1242
1249
@@ -1830,14 +1837,16 @@ PHP_FUNCTION(imap_unsubscribe)
1830
1837
Read the full structure of a message */
1831
1838
PHP_FUNCTION (imap_fetchstructure )
1832
1839
{
1833
- zval * * streamind , * * msgno , * * flags ;
1840
+ zval * * streamind , * * msgno , * * pflags ;
1834
1841
pils * imap_le_struct ;
1835
1842
BODY * body ;
1836
1843
int msgindex , myargc = ZEND_NUM_ARGS ();
1844
+ long flags = 0L ;
1837
1845
1838
- if (myargc < 2 || myargc > 3 || zend_get_parameters_ex (myargc , & streamind , & msgno , & flags ) == FAILURE ) {
1846
+ if (myargc < 2 || myargc > 3 || zend_get_parameters_ex (myargc , & streamind , & msgno , & pflags ) == FAILURE ) {
1839
1847
ZEND_WRONG_PARAM_COUNT ();
1840
1848
}
1849
+
1841
1850
1842
1851
ZEND_FETCH_RESOURCE (imap_le_struct , pils * , streamind , -1 , "imap" , le_imap );
1843
1852
@@ -1846,12 +1855,18 @@ PHP_FUNCTION(imap_fetchstructure)
1846
1855
RETURN_FALSE ;
1847
1856
}
1848
1857
if (myargc == 3 ) {
1849
- convert_to_long_ex (flags );
1858
+ convert_to_long_ex (pflags );
1859
+ flags = Z_LVAL_PP (pflags );
1860
+
1861
+ if (flags && ((flags & ~FT_UID ) != 0 )) {
1862
+ php_error_docref (NULL TSRMLS_CC , E_WARNING , "invalid value for the options parameter" );
1863
+ RETURN_FALSE ;
1864
+ }
1850
1865
}
1851
1866
1852
1867
object_init (return_value );
1853
1868
1854
- if ((myargc == 3 ) && (Z_LVAL_PP ( flags ) & FT_UID )) {
1869
+ if ((myargc == 3 ) && (flags & FT_UID )) {
1855
1870
/* This should be cached; if it causes an extra RTT to the
1856
1871
IMAP server, then that's the price we pay for making
1857
1872
sure we don't crash. */
@@ -1861,7 +1876,7 @@ PHP_FUNCTION(imap_fetchstructure)
1861
1876
}
1862
1877
PHP_IMAP_CHECK_MSGNO (msgindex );
1863
1878
1864
- mail_fetchstructure_full (imap_le_struct -> imap_stream , Z_LVAL_PP (msgno ), & body , myargc == 3 ? Z_LVAL_PP (flags ) : NIL );
1879
+ mail_fetchstructure_full (imap_le_struct -> imap_stream , Z_LVAL_PP (msgno ), & body , myargc == 3 ? Z_LVAL_PP (pflags ) : NIL );
1865
1880
1866
1881
if (!body ) {
1867
1882
php_error_docref (NULL TSRMLS_CC , E_WARNING , "No body information available" );
@@ -1876,30 +1891,37 @@ PHP_FUNCTION(imap_fetchstructure)
1876
1891
Get a specific body section */
1877
1892
PHP_FUNCTION (imap_fetchbody )
1878
1893
{
1879
- zval * * streamind , * * msgno , * * sec , * * flags ;
1894
+ zval * * streamind , * * msgno , * * sec , * * pflags ;
1880
1895
pils * imap_le_struct ;
1881
1896
char * body ;
1897
+ long flags = 0L ;
1882
1898
unsigned long len ;
1883
1899
int myargc = ZEND_NUM_ARGS ();
1884
1900
1885
- if (myargc < 3 || myargc > 4 || zend_get_parameters_ex (myargc , & streamind , & msgno , & sec , & flags ) == FAILURE ) {
1901
+ if (myargc < 3 || myargc > 4 || zend_get_parameters_ex (myargc , & streamind , & msgno , & sec , & pflags ) == FAILURE ) {
1886
1902
ZEND_WRONG_PARAM_COUNT ();
1887
1903
}
1888
1904
1905
+
1889
1906
ZEND_FETCH_RESOURCE (imap_le_struct , pils * , streamind , -1 , "imap" , le_imap );
1890
1907
1891
1908
convert_to_long_ex (msgno );
1892
1909
convert_to_string_ex (sec );
1893
1910
if (myargc == 4 ) {
1894
- convert_to_long_ex (flags );
1911
+ convert_to_long_ex (pflags );
1912
+ flags = Z_LVAL_PP (pflags );
1913
+ if (flags && ((flags & ~(FT_UID |FT_PEEK |FT_INTERNAL )) != 0 )) {
1914
+ php_error_docref (NULL TSRMLS_CC , E_WARNING , "invalid value for the options parameter" );
1915
+ RETURN_FALSE ;
1916
+ }
1895
1917
}
1896
1918
1897
- if (myargc < 4 || !(Z_LVAL_PP ( flags ) & FT_UID )) {
1919
+ if (myargc < 4 || !(flags & FT_UID )) {
1898
1920
/* only perform the check if the msgno is a message number and not a UID */
1899
1921
PHP_IMAP_CHECK_MSGNO (Z_LVAL_PP (msgno ));
1900
1922
}
1901
1923
1902
- body = mail_fetchbody_full (imap_le_struct -> imap_stream , Z_LVAL_PP (msgno ), Z_STRVAL_PP (sec ), & len , myargc == 4 ? Z_LVAL_PP (flags ) : NIL );
1924
+ body = mail_fetchbody_full (imap_le_struct -> imap_stream , Z_LVAL_PP (msgno ), Z_STRVAL_PP (sec ), & len , myargc == 4 ? Z_LVAL_PP (pflags ) : NIL );
1903
1925
1904
1926
if (!body ) {
1905
1927
php_error_docref (NULL TSRMLS_CC , E_WARNING , "No body information available" );
@@ -2640,22 +2662,29 @@ PHP_FUNCTION(imap_sort)
2640
2662
Get the full unfiltered header for a message */
2641
2663
PHP_FUNCTION (imap_fetchheader )
2642
2664
{
2643
- zval * * streamind , * * msgno , * * flags ;
2665
+ zval * * streamind , * * msgno , * * pflags ;
2644
2666
pils * imap_le_struct ;
2645
2667
int msgindex , myargc = ZEND_NUM_ARGS ();
2668
+ long flags = 0L ;
2646
2669
2647
- if (myargc < 2 || myargc > 3 || zend_get_parameters_ex (myargc , & streamind , & msgno , & flags ) == FAILURE ) {
2670
+ if (myargc < 2 || myargc > 3 || zend_get_parameters_ex (myargc , & streamind , & msgno , & pflags ) == FAILURE ) {
2648
2671
ZEND_WRONG_PARAM_COUNT ();
2649
2672
}
2650
-
2673
+
2651
2674
ZEND_FETCH_RESOURCE (imap_le_struct , pils * , streamind , -1 , "imap" , le_imap );
2652
2675
2653
2676
convert_to_long_ex (msgno );
2654
2677
if (myargc == 3 ) {
2655
- convert_to_long_ex (flags );
2656
- }
2678
+ convert_to_long_ex (pflags );
2679
+ flags = Z_LVAL_PP (pflags );
2680
+ if (flags && ((flags & ~(FT_UID |FT_INTERNAL |FT_PREFETCHTEXT )) != 0 )) {
2681
+ php_error_docref (NULL TSRMLS_CC , E_WARNING , "invalid value for the options parameter" );
2682
+ RETURN_FALSE ;
2683
+ }
2684
+ }
2685
+
2657
2686
2658
- if ((myargc == 3 ) && (Z_LVAL_PP ( flags ) & FT_UID )) {
2687
+ if ((myargc == 3 ) && (flags & FT_UID )) {
2659
2688
/* This should be cached; if it causes an extra RTT to the
2660
2689
IMAP server, then that's the price we pay for making sure
2661
2690
we don't crash. */
@@ -2666,7 +2695,7 @@ PHP_FUNCTION(imap_fetchheader)
2666
2695
2667
2696
PHP_IMAP_CHECK_MSGNO (msgindex );
2668
2697
2669
- RETVAL_STRING (mail_fetchheader_full (imap_le_struct -> imap_stream , Z_LVAL_PP (msgno ), NIL , NIL , (myargc == 3 ? Z_LVAL_PP (flags ) : NIL )), 1 );
2698
+ RETVAL_STRING (mail_fetchheader_full (imap_le_struct -> imap_stream , Z_LVAL_PP (msgno ), NIL , NIL , (myargc == 3 ? Z_LVAL_PP (pflags ) : NIL )), 1 );
2670
2699
}
2671
2700
/* }}} */
2672
2701
@@ -2889,6 +2918,7 @@ PHP_FUNCTION(imap_fetch_overview)
2889
2918
ZEND_WRONG_PARAM_COUNT ();
2890
2919
}
2891
2920
2921
+
2892
2922
ZEND_FETCH_RESOURCE (imap_le_struct , pils * , streamind , -1 , "imap" , le_imap );
2893
2923
2894
2924
convert_to_string_ex (sequence );
0 commit comments