File tree Expand file tree Collapse file tree 1 file changed +17
-0
lines changed
Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -1685,6 +1685,23 @@ PHP_FUNCTION(socket_recvfrom)
16851685 case ETH_P_IP : {
16861686 payload = ((unsigned char * )e + ETH_HLEN );
16871687 struct iphdr * ip = (struct iphdr * )payload ;
1688+ size_t tlayer = ip -> ihl * 4 ;
1689+ size_t totalip = ntohs (ip -> tot_len );
1690+
1691+ if (tlayer < sizeof (* ip ) || totalip < tlayer ) {
1692+ ZVAL_NULL (& zpayload );
1693+ zend_update_property (Z_OBJCE (obj ), Z_OBJ (obj ), ZEND_STRL ("payload" ), & zpayload );
1694+ zend_update_property_string (Z_OBJCE (obj ), Z_OBJ (obj ), ZEND_STRL ("rawpacket" ), ZSTR_VAL (recv_buf ));
1695+ zend_string_efree (recv_buf );
1696+ ZEND_TRY_ASSIGN_REF_VALUE (arg2 , & obj );
1697+ ZEND_TRY_ASSIGN_REF_STRING (arg5 , ifrname );
1698+
1699+ if (arg6 ) {
1700+ ZEND_TRY_ASSIGN_REF_LONG (arg6 , sll .sll_ifindex );
1701+ }
1702+ zend_value_error ("invalid transport header length" );
1703+ RETURN_THROWS ();
1704+ }
16881705 unsigned char * ipdata = payload + (ip -> ihl * 4 );
16891706 struct in_addr s , d ;
16901707 s .s_addr = ip -> saddr ;
You can’t perform that action at this time.
0 commit comments