forked from KolibriOS/kolibrios
add proper error handling for socket functions
git-svn-id: svn://kolibrios.org@6437 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
ed33bcec93
commit
f105b9cfdf
@ -29,8 +29,10 @@ resolve:
|
|||||||
.user:
|
.user:
|
||||||
lodsb
|
lodsb
|
||||||
cmp al, 0
|
cmp al, 0
|
||||||
je .error
|
jne @f
|
||||||
stosb
|
mov eax, str_err_params
|
||||||
|
jmp error
|
||||||
|
@@: stosb
|
||||||
cmp byte [esi], ':'
|
cmp byte [esi], ':'
|
||||||
jne .user
|
jne .user
|
||||||
mov word [edi], 0x0a0d
|
mov word [edi], 0x0a0d
|
||||||
@ -44,8 +46,10 @@ resolve:
|
|||||||
.pass:
|
.pass:
|
||||||
lodsb
|
lodsb
|
||||||
cmp al, 0
|
cmp al, 0
|
||||||
je .error
|
jne @f
|
||||||
stosb
|
mov eax, str_err_params
|
||||||
|
jmp error
|
||||||
|
@@: stosb
|
||||||
cmp byte [esi], '@'
|
cmp byte [esi], '@'
|
||||||
jne .pass
|
jne .pass
|
||||||
mov word [edi], 0x0a0d
|
mov word [edi], 0x0a0d
|
||||||
@ -57,8 +61,10 @@ resolve:
|
|||||||
.addr:
|
.addr:
|
||||||
lodsb
|
lodsb
|
||||||
cmp al, 0
|
cmp al, 0
|
||||||
je .error
|
jne @f
|
||||||
stosb
|
mov eax, str_err_params
|
||||||
|
jmp error
|
||||||
|
@@: stosb
|
||||||
cmp byte [esi], ':'
|
cmp byte [esi], ':'
|
||||||
jne .addr
|
jne .addr
|
||||||
mov byte [edi], 0
|
mov byte [edi], 0
|
||||||
@ -71,18 +77,24 @@ resolve:
|
|||||||
.port:
|
.port:
|
||||||
lodsb
|
lodsb
|
||||||
cmp al, 0
|
cmp al, 0
|
||||||
je .error
|
jne @f
|
||||||
cmp al, '/'
|
mov eax, str_err_params
|
||||||
jbe @f
|
jmp error
|
||||||
|
@@: cmp al, '/'
|
||||||
|
jbe .port_done
|
||||||
sub al, '0'
|
sub al, '0'
|
||||||
jb error_hostname
|
jnb @f
|
||||||
cmp al, 9
|
mov eax, str_err_host
|
||||||
ja error_hostname
|
jmp error
|
||||||
lea ebx, [ebx*4 + ebx]
|
@@: cmp al, 9
|
||||||
|
jna @f
|
||||||
|
mov eax, str_err_host
|
||||||
|
jmp error
|
||||||
|
@@: lea ebx, [ebx*4 + ebx]
|
||||||
shl ebx, 1
|
shl ebx, 1
|
||||||
add ebx, eax
|
add ebx, eax
|
||||||
jmp .port
|
jmp .port
|
||||||
@@: ; port done
|
.port_done:
|
||||||
xchg bl, bh
|
xchg bl, bh
|
||||||
mov [sockaddr1.port], bx
|
mov [sockaddr1.port], bx
|
||||||
|
|
||||||
@ -112,5 +124,3 @@ resolve:
|
|||||||
|
|
||||||
jmp no_resolve.done
|
jmp no_resolve.done
|
||||||
|
|
||||||
.error:
|
|
||||||
jmp main ; parameter resolution failed. get input from user
|
|
@ -84,8 +84,10 @@ pasv_ok:
|
|||||||
|
|
||||||
mcall socket, AF_INET4, SOCK_STREAM, 0
|
mcall socket, AF_INET4, SOCK_STREAM, 0
|
||||||
cmp eax, -1
|
cmp eax, -1
|
||||||
je error_socket
|
jne @f
|
||||||
mov [datasocket], eax
|
mov eax, str_err_socket
|
||||||
|
jmp error
|
||||||
|
@@: mov [datasocket], eax
|
||||||
|
|
||||||
mov esi, edi
|
mov esi, edi
|
||||||
call ascii_dec
|
call ascii_dec
|
||||||
@ -105,8 +107,10 @@ pasv_ok:
|
|||||||
invoke con_write_asciiz, str_open
|
invoke con_write_asciiz, str_open
|
||||||
mcall connect, [datasocket], sockaddr2, 18
|
mcall connect, [datasocket], sockaddr2, 18
|
||||||
cmp eax, -1
|
cmp eax, -1
|
||||||
je error_socket
|
jne @f
|
||||||
jmp wait_for_servercommand
|
mov eax, str_err_connect
|
||||||
|
jmp error
|
||||||
|
@@: jmp wait_for_servercommand
|
||||||
|
|
||||||
.fail:
|
.fail:
|
||||||
invoke con_write_asciiz, str_unknown
|
invoke con_write_asciiz, str_unknown
|
||||||
|
Loading…
Reference in New Issue
Block a user