mirror of
https://github.com/KolibriOS/kolibrios.git
synced 2024-12-23 23:26:49 +03:00
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:
|
||||
lodsb
|
||||
cmp al, 0
|
||||
je .error
|
||||
stosb
|
||||
jne @f
|
||||
mov eax, str_err_params
|
||||
jmp error
|
||||
@@: stosb
|
||||
cmp byte [esi], ':'
|
||||
jne .user
|
||||
mov word [edi], 0x0a0d
|
||||
@ -44,8 +46,10 @@ resolve:
|
||||
.pass:
|
||||
lodsb
|
||||
cmp al, 0
|
||||
je .error
|
||||
stosb
|
||||
jne @f
|
||||
mov eax, str_err_params
|
||||
jmp error
|
||||
@@: stosb
|
||||
cmp byte [esi], '@'
|
||||
jne .pass
|
||||
mov word [edi], 0x0a0d
|
||||
@ -57,8 +61,10 @@ resolve:
|
||||
.addr:
|
||||
lodsb
|
||||
cmp al, 0
|
||||
je .error
|
||||
stosb
|
||||
jne @f
|
||||
mov eax, str_err_params
|
||||
jmp error
|
||||
@@: stosb
|
||||
cmp byte [esi], ':'
|
||||
jne .addr
|
||||
mov byte [edi], 0
|
||||
@ -71,18 +77,24 @@ resolve:
|
||||
.port:
|
||||
lodsb
|
||||
cmp al, 0
|
||||
je .error
|
||||
cmp al, '/'
|
||||
jbe @f
|
||||
jne @f
|
||||
mov eax, str_err_params
|
||||
jmp error
|
||||
@@: cmp al, '/'
|
||||
jbe .port_done
|
||||
sub al, '0'
|
||||
jb error_hostname
|
||||
cmp al, 9
|
||||
ja error_hostname
|
||||
lea ebx, [ebx*4 + ebx]
|
||||
jnb @f
|
||||
mov eax, str_err_host
|
||||
jmp error
|
||||
@@: cmp al, 9
|
||||
jna @f
|
||||
mov eax, str_err_host
|
||||
jmp error
|
||||
@@: lea ebx, [ebx*4 + ebx]
|
||||
shl ebx, 1
|
||||
add ebx, eax
|
||||
jmp .port
|
||||
@@: ; port done
|
||||
.port_done:
|
||||
xchg bl, bh
|
||||
mov [sockaddr1.port], bx
|
||||
|
||||
@ -112,5 +124,3 @@ resolve:
|
||||
|
||||
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
|
||||
cmp eax, -1
|
||||
je error_socket
|
||||
mov [datasocket], eax
|
||||
jne @f
|
||||
mov eax, str_err_socket
|
||||
jmp error
|
||||
@@: mov [datasocket], eax
|
||||
|
||||
mov esi, edi
|
||||
call ascii_dec
|
||||
@ -105,8 +107,10 @@ pasv_ok:
|
||||
invoke con_write_asciiz, str_open
|
||||
mcall connect, [datasocket], sockaddr2, 18
|
||||
cmp eax, -1
|
||||
je error_socket
|
||||
jmp wait_for_servercommand
|
||||
jne @f
|
||||
mov eax, str_err_connect
|
||||
jmp error
|
||||
@@: jmp wait_for_servercommand
|
||||
|
||||
.fail:
|
||||
invoke con_write_asciiz, str_unknown
|
||||
|
Loading…
Reference in New Issue
Block a user