add proper error handling for socket functions

git-svn-id: svn://kolibrios.org@6437 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
nisargshah95 2016-05-28 10:18:22 +00:00
parent ed33bcec93
commit f105b9cfdf
2 changed files with 34 additions and 20 deletions

View File

@ -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

View File

@ -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