FTPd: bugfix: do not send 0 byte in PASV and PWD replies.

git-svn-id: svn://kolibrios.org@3824 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
hidnplayr 2013-07-15 10:49:21 +00:00
parent f3c95fbee0
commit e6158a19a8
2 changed files with 23 additions and 9 deletions

View File

@ -90,7 +90,7 @@ commands: ; all commands must be in uppercase
; dd 'MDTM', login_first, login_first, login_first, cmd_MDTM ; dd 'MDTM', login_first, login_first, login_first, cmd_MDTM
; dd 'MKD', login_first, login_first, login_first, cmd_MKD ; dd 'MKD', login_first, login_first, login_first, cmd_MKD
; dd 'MODE', login_first, login_first, login_first, cmd_MODE ; dd 'MODE', login_first, login_first, login_first, cmd_MODE
dd 'NLST', login_first, login_first, login_first, cmdNLST ; dd 'NLST', login_first, login_first, login_first, cmdNLST
dd 'NOOP', login_first, login_first, login_first, cmdNOOP dd 'NOOP', login_first, login_first, login_first, cmdNOOP
dd 'PASS', cmdPASS.0, cmdPASS , cmdPASS.2, cmdPASS.3 dd 'PASS', cmdPASS.0, cmdPASS , cmdPASS.2, cmdPASS.3
dd 'PASV', login_first, login_first, login_first, cmdPASV dd 'PASV', login_first, login_first, login_first, cmdPASV
@ -283,9 +283,9 @@ align 4
open_datasock: open_datasock:
cmp [ebp + thread_data.mode], MODE_PASSIVE_OK cmp [ebp + thread_data.mode], MODE_PASSIVE_OK
je .start je .already_open
; If we are in active mode, it's time to open a data socket.. ; If we are in active mode, it's time to open the data socket..
cmp [ebp + thread_data.mode], MODE_ACTIVE cmp [ebp + thread_data.mode], MODE_ACTIVE
jne .not_active jne .not_active
mov ecx, [ebp + thread_data.datasocketnum] mov ecx, [ebp + thread_data.datasocketnum]
@ -293,7 +293,13 @@ open_datasock:
mov esi, sizeof.thread_data.datasock mov esi, sizeof.thread_data.datasock
mcall connect mcall connect
cmp eax, -1 cmp eax, -1
jne .start je .socketerror
invoke con_write_asciiz, str_datasock2
ret
.already_open:
invoke con_write_asciiz, str_alopen
ret
.socketerror: .socketerror:
add esp, 4 add esp, 4
@ -323,7 +329,6 @@ open_datasock:
mov [ebp + thread_data.passivesocknum], -1 mov [ebp + thread_data.passivesocknum], -1
invoke con_write_asciiz, str_datasock invoke con_write_asciiz, str_datasock
.start:
ret ret
@ -600,7 +605,7 @@ cmdLIST:
mov [ebp + thread_data.mode], MODE_NOTREADY mov [ebp + thread_data.mode], MODE_NOTREADY
mcall close, [ebp + thread_data.datasocketnum] mcall close, [ebp + thread_data.datasocketnum]
sendFTP "226 Transfer OK" sendFTP "226 List OK"
ret ret
.nosuchdir: .nosuchdir:
@ -773,13 +778,15 @@ cmdPASV:
mov eax, ')' + (0x000a0d shl 8) mov eax, ')' + (0x000a0d shl 8)
stosd stosd
lea esi, [edi - thread_data.buffer] lea esi, [edi - thread_data.buffer - 1] ; calculate length, do not cound the trailing 0 byte
sub esi, ebp sub esi, ebp
mov ecx, [ebp + thread_data.socketnum] mov ecx, [ebp + thread_data.socketnum]
lea edx, [ebp + thread_data.buffer] lea edx, [ebp + thread_data.buffer]
xor edi, edi xor edi, edi
mcall send mcall send
invoke con_write_asciiz, edx
ret ret
@ -813,7 +820,7 @@ cmdPWD:
.ok: .ok:
mov dword [edi], '"' + 0x000a0d00 ; '"',13,10,0 mov dword [edi], '"' + 0x000a0d00 ; '"',13,10,0
lea esi, [edi - thread_data.buffer + 4] lea esi, [edi - thread_data.buffer + 3]
sub esi, ebp sub esi, ebp
mov ecx, [ebp + thread_data.socketnum] mov ecx, [ebp + thread_data.socketnum]
lea edx, [ebp + thread_data.buffer] lea edx, [ebp + thread_data.buffer]
@ -991,13 +998,18 @@ cmdSTOR:
test [ebp + thread_data.permissions], PERMISSION_WRITE test [ebp + thread_data.permissions], PERMISSION_WRITE
jz permission_denied jz permission_denied
sendFTP " Ready to receive"
;;;; TODO
;;;;
test [ebp + thread_data.permissions], ABORT test [ebp + thread_data.permissions], ABORT
jnz abort_transfer jnz abort_transfer
;;;; ;;;;
sendFTP "226 Transfer OK"
ret ret
;------------------------------------------------ ;------------------------------------------------

View File

@ -358,6 +358,8 @@ str_pass_err db 'Password/Username incorrect',10,0
str_pwd db 'Current directory is "%s"\n',0 str_pwd db 'Current directory is "%s"\n',0
str_err2 db 'ERROR: cannot open the directory.',10,0 str_err2 db 'ERROR: cannot open the directory.',10,0
str_datasock db 'Passive data socket connected.',10,0 str_datasock db 'Passive data socket connected.',10,0
str_datasock2 db 'Active data socket connected.',10,0
str_alopen db 'Data connection already open.',10,0
str_notfound db 'ERROR: file not found.',10,0 str_notfound db 'ERROR: file not found.',10,0
str_sockerr db 'ERROR: socket error.',10,0 str_sockerr db 'ERROR: socket error.',10,0