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
STATUS_DISCONNECTED = 0
@ -572,6 +572,8 @@ status dd STATUS_DISCONNECTED
window_active dd windows
window_print dd windows
cmd_remaining dd 0
align 4
@IMPORT:

View File

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

View File

@ -210,9 +210,7 @@ socket_receive:
pusha
; FIXME: make this a proper stream!
.nextpacket:
.recv_more:
mcall recv, [socketnum], packetbuf , PACKETBUF_SIZE, MSG_DONTWAIT ; read a packet
inc eax ; check if we got any data
jz .done ; TODO: handle errors!
@ -223,17 +221,19 @@ socket_receive:
mov ecx, eax
mov esi, packetbuf ; esi = start pointer
.nextcommand:
mov edi, servercommand
add edi, [cmd_remaining]
.byteloop:
test ecx, ecx
jz .nextpacket
jz .recv_more
lodsb
dec ecx
cmp al, 10
je .got_command
cmp al, 13
je .got_command
cmp edi, servercommand + SERVERCOMMAND_SIZE ; Prevent command buffer overflow
jae .byteloop
stosb
jmp .byteloop
@ -249,7 +249,11 @@ socket_receive:
sub ecx, servercommand ; put length in ecx
call server_parser
pop ecx esi
jmp .nextcommand
.nextcommand:
mov edi, servercommand
mov [cmd_remaining], ecx ; remaining bytes since last EOL
jmp .byteloop
.done:
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 ;;
;; ;;
;; Written by hidnplayr@kolibrios.org ;;
@ -24,6 +24,7 @@ user_add:
cmp [ebx + window.users], MAX_USERS
jae .fail
; Check if user is already listed (case insensitive)
mov edi, [ebx + window.data_ptr]
add edi, window_data.names
mov ebp, [ebx + window.users]
@ -107,6 +108,8 @@ user_add:
je .done
cmp al, 10
je .done
cmp al, 0
je .done
stosb
loop .fill
.done:
@ -115,6 +118,7 @@ user_add:
inc [ebx + window.users]
or [ebx + window.flags], FLAG_UPDATED
dec esi
.fail:
ret