Fixed bug when parsing JOIN command.

Implemented proper handeling of partially received commands.

git-svn-id: svn://kolibrios.org@9984 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
hidnplayr 2024-03-05 09:49:00 +00:00
parent 473786717d
commit eb7e44a0e0
4 changed files with 33 additions and 18 deletions

View File

@ -13,7 +13,7 @@
;; ;; ;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
version equ '0.35c' version equ '0.36'
; connection status ; connection status
STATUS_DISCONNECTED = 0 STATUS_DISCONNECTED = 0
@ -572,6 +572,8 @@ status dd STATUS_DISCONNECTED
window_active dd windows window_active dd windows
window_print dd windows window_print dd windows
cmd_remaining dd 0
align 4 align 4
@IMPORT: @IMPORT:

View File

@ -548,6 +548,10 @@ cmd_part:
cmp byte [esi+4], ' ' cmp byte [esi+4], ' '
jne .fail jne .fail
add esi, 5 ; skip 'PART ' add esi, 5 ; skip 'PART '
cmp byte[esi], ':'
jne @f
inc esi
@@:
; Is it me who parted? ; Is it me who parted?
mov edi, servercommand+1 mov edi, servercommand+1
@ -610,6 +614,10 @@ cmd_join:
cmp byte[esi+4], ' ' cmp byte[esi+4], ' '
jne .fail jne .fail
add esi, 5 ; skip 'JOIN ' add esi, 5 ; skip 'JOIN '
cmp byte[esi], ':'
jne @f
inc esi
@@:
; did we join a channel? ; did we join a channel?
mov edi, servercommand+1 mov edi, servercommand+1
@ -982,22 +990,19 @@ cmd_353: ; channel usernames reply
; TODO: remove all users? ; TODO: remove all users?
.add: .add:
push esi
call user_add
pop esi
.namesloop:
lodsb lodsb
test al, al test al, al
jz .done jz .done
cmp al, ' ' ; names list is separated with spaces cmp al, ' '
jne .namesloop je .add
dec esi
call user_add
jmp .add jmp .add
.done: .done:
call draw_user_list call draw_user_list
.fail:
.fail:
ret ret

View File

@ -210,9 +210,7 @@ socket_receive:
pusha pusha
; FIXME: make this a proper stream! .recv_more:
.nextpacket:
mcall recv, [socketnum], packetbuf , PACKETBUF_SIZE, MSG_DONTWAIT ; read a packet mcall recv, [socketnum], packetbuf , PACKETBUF_SIZE, MSG_DONTWAIT ; read a packet
inc eax ; check if we got any data inc eax ; check if we got any data
jz .done ; TODO: handle errors! jz .done ; TODO: handle errors!
@ -223,17 +221,19 @@ socket_receive:
mov ecx, eax mov ecx, eax
mov esi, packetbuf ; esi = start pointer mov esi, packetbuf ; esi = start pointer
.nextcommand:
mov edi, servercommand mov edi, servercommand
add edi, [cmd_remaining]
.byteloop: .byteloop:
test ecx, ecx test ecx, ecx
jz .nextpacket jz .recv_more
lodsb lodsb
dec ecx dec ecx
cmp al, 10 cmp al, 10
je .got_command je .got_command
cmp al, 13 cmp al, 13
je .got_command je .got_command
cmp edi, servercommand + SERVERCOMMAND_SIZE ; Prevent command buffer overflow
jae .byteloop
stosb stosb
jmp .byteloop jmp .byteloop
@ -249,7 +249,11 @@ socket_receive:
sub ecx, servercommand ; put length in ecx sub ecx, servercommand ; put length in ecx
call server_parser call server_parser
pop ecx esi pop ecx esi
jmp .nextcommand
.nextcommand:
mov edi, servercommand
mov [cmd_remaining], ecx ; remaining bytes since last EOL
jmp .byteloop
.done: .done:
popa popa

View File

@ -1,6 +1,6 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;; ;; ;;
;; Copyright (C) KolibriOS team 2004-2016. All rights reserved. ;; ;; Copyright (C) KolibriOS team 2004-2024. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License ;; ;; Distributed under terms of the GNU General Public License ;;
;; ;; ;; ;;
;; Written by hidnplayr@kolibrios.org ;; ;; Written by hidnplayr@kolibrios.org ;;
@ -24,6 +24,7 @@ user_add:
cmp [ebx + window.users], MAX_USERS cmp [ebx + window.users], MAX_USERS
jae .fail jae .fail
; Check if user is already listed (case insensitive)
mov edi, [ebx + window.data_ptr] mov edi, [ebx + window.data_ptr]
add edi, window_data.names add edi, window_data.names
mov ebp, [ebx + window.users] mov ebp, [ebx + window.users]
@ -107,6 +108,8 @@ user_add:
je .done je .done
cmp al, 10 cmp al, 10
je .done je .done
cmp al, 0
je .done
stosb stosb
loop .fill loop .fill
.done: .done:
@ -115,6 +118,7 @@ user_add:
inc [ebx + window.users] inc [ebx + window.users]
or [ebx + window.flags], FLAG_UPDATED or [ebx + window.flags], FLAG_UPDATED
dec esi
.fail: .fail:
ret ret