:(
This commit is contained in:
@@ -12,11 +12,10 @@ ft_strdup:
|
|||||||
call malloc wrt ..plt
|
call malloc wrt ..plt
|
||||||
test rax, rax
|
test rax, rax
|
||||||
je .end
|
je .end
|
||||||
pop r8
|
pop rsi
|
||||||
mov rdi, rax ; move the result of malloc into rdi (override strlen result)
|
mov rdi, rax ; move the result of malloc into rdi (override strlen result)
|
||||||
mov rsi, r8 ; move the argument of strdup in rsi
|
|
||||||
call ft_strcpy
|
call ft_strcpy
|
||||||
ret
|
ret
|
||||||
|
|
||||||
.end:
|
.end:
|
||||||
pop r8
|
pop r8
|
||||||
|
|||||||
16
ft_write.s
16
ft_write.s
@@ -2,12 +2,28 @@ global ft_write
|
|||||||
extern __errno_location
|
extern __errno_location
|
||||||
|
|
||||||
ft_write:
|
ft_write:
|
||||||
|
cmp rdi, 0
|
||||||
|
jl .err_fd
|
||||||
|
test rsi, rsi
|
||||||
|
je .err_buffer
|
||||||
mov eax, 0x1 ; put the syscall number of write
|
mov eax, 0x1 ; put the syscall number of write
|
||||||
syscall
|
syscall
|
||||||
test rax, rax
|
test rax, rax
|
||||||
js .error
|
js .error
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
.err_fd:
|
||||||
|
call __errno_location wrt ..plt
|
||||||
|
mov byte [rax], 22
|
||||||
|
mov rax, -1
|
||||||
|
ret
|
||||||
|
|
||||||
|
.err_buffer:
|
||||||
|
call __errno_location wrt ..plt
|
||||||
|
mov byte [rax], 22
|
||||||
|
mov rax, -1
|
||||||
|
ret
|
||||||
|
|
||||||
.error:
|
.error:
|
||||||
mov rdx, rax
|
mov rdx, rax
|
||||||
call __errno_location wrt ..plt
|
call __errno_location wrt ..plt
|
||||||
|
|||||||
Reference in New Issue
Block a user