IPv4: Dont crash when there is no route to host.

git-svn-id: svn://kolibrios.org@6122 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
hidnplayr 2016-02-01 19:43:10 +00:00
parent 63743484d7
commit cbca315c7d
2 changed files with 16 additions and 7 deletions

View File

@ -1,6 +1,6 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; Copyright (C) KolibriOS team 2004-2015. All rights reserved. ;; Copyright (C) KolibriOS team 2004-2016. All rights reserved.
;; PROGRAMMING: ;; PROGRAMMING:
;; Ivan Poddubny ;; Ivan Poddubny
;; Marat Zakiyanov (Mario79) ;; Marat Zakiyanov (Mario79)
@ -2177,7 +2177,7 @@ sys_end:
@@: @@:
mov eax, [TASK_BASE] mov eax, [TASK_BASE]
mov [eax+TASKDATA.state], 3; terminate this program mov [eax+TASKDATA.state], TSTATE_ZOMBIE
call wakeup_osloop call wakeup_osloop
.waitterm: ; wait here for termination .waitterm: ; wait here for termination
@ -3746,7 +3746,7 @@ nobackgr:
align 4 align 4
markz: markz:
push ecx edx push ecx edx
cmp [edx+TASKDATA.state], 9 cmp [edx+TASKDATA.state], TSTATE_FREE
jz .nokill jz .nokill
lea edx, [(edx-(CURRENT_TASK and 1FFFFFFFh))*8+SLOT_BASE] lea edx, [(edx-(CURRENT_TASK and 1FFFFFFFh))*8+SLOT_BASE]
cmp [edx+APPDATA.process], sys_proc cmp [edx+APPDATA.process], sys_proc
@ -3760,7 +3760,7 @@ markz:
pop edx ecx pop edx ecx
test eax, eax test eax, eax
jz @f jz @f
mov [edx+TASKDATA.state], byte 3 mov [edx+TASKDATA.state], TSTATE_ZOMBIE
@@: @@:
add edx, 0x20 add edx, 0x20
loop markz loop markz

View File

@ -1,6 +1,6 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;; ;; ;;
;; Copyright (C) KolibriOS team 2004-2015. All rights reserved. ;; ;; Copyright (C) KolibriOS team 2004-2016. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License ;; ;; Distributed under terms of the GNU General Public License ;;
;; ;; ;; ;;
;; IPv4.INC ;; ;; IPv4.INC ;;
@ -634,6 +634,8 @@ ipv4_output:
push ecx ax edi push ecx ax edi
mov eax, edi mov eax, edi
call ipv4_route ; outputs device number in edi, dest ip in eax, source IP in edx call ipv4_route ; outputs device number in edi, dest ip in eax, source IP in edx
test eax, eax
jz .no_route
push edx push edx
test edi, edi test edi, edi
jz .loopback jz .loopback
@ -683,6 +685,12 @@ ipv4_output:
xor eax, eax xor eax, eax
ret ret
.no_route:
DEBUGF DEBUG_NETWORK_ERROR, "IPv4_output: No route to host!\n"
add esp, 2*4+2
xor eax, eax
ret
.arp_error: .arp_error:
DEBUGF DEBUG_NETWORK_ERROR, "IPv4_output: ARP error=%x\n", eax DEBUGF DEBUG_NETWORK_ERROR, "IPv4_output: ARP error=%x\n", eax
add esp, 4 add esp, 4
@ -917,7 +925,7 @@ endp
; ebx = outgoing device / 0 ; ; ebx = outgoing device / 0 ;
; edx = Source IP ; ; edx = Source IP ;
; ; ; ;
; OUT: eax = Destination IP (or gateway IP) ; ; OUT: eax = Destination IP (may be gateway), 0 on error ;
; edx = Source IP ; ; edx = Source IP ;
; edi = device number*4 ; ; edi = device number*4 ;
; ; ; ;
@ -926,7 +934,7 @@ endp
; ; ; ;
;-----------------------------------------------------------------; ;-----------------------------------------------------------------;
align 4 align 4
ipv4_route: ; TODO: return error if no valid route found ipv4_route:
test ebx, ebx test ebx, ebx
jnz .got_device jnz .got_device
@ -979,6 +987,7 @@ ipv4_route: ; TODO: return error if no valid route found
ret ret
.fail: .fail:
xor eax, eax
ret ret