Control: retitle -1 ltrace: [p]{read,write}[v]() handling, common *64() 
functions in modern glibc, [fl]seek[o]()/ftell[o](); requisite [u]llong; 20x 
speed optimisation in default config; format %b+bin() lens and %w[f]32x; 
splice/c_f_r/sendfile[64] formatting; useful __errno_location

Attaching two patches that turn
  splice(3, 0x7ffca660acd8, 1, 0)                                               
                            = -1
  copy_file_range(3, 0x7ffca660acd8, 1, 0)                                      
                            = -1
  sendfile64(1, 3, 0x7ffca660acd8, 0x400000)                                    
                            = -1
  pread64(3 <no return ...>
  error: maximum array length seems negative
  , "", 65536, -65536)                                                          
                            = -1
  __errno_location()                                                            
                            = 0x7f5347bb86c0
  __errno_location()                                                            
                            = 0x7f5347bb86c0
  strerror(22)                                                                  
                            = "Invalid argument"
  fprintf(0x7f5347d8e680, "%s: %s: %s\n", "out/cmd/tail", "5M", "Invalid 
argument")                         = 35
  close(3)                                                                      
                            = 0
  __cxa_finalize(0x561787e1efd8)                                                
                            = <void>
  +++ exited (status 1) +++
into
  splice(3, -65536, 1, nil, 4194304, 0b101)                                     
                            = -1
  copy_file_range(3, -65536, 1, nil, 4194304, 0)                                
                            = -1
  sendfile64(1, 3, -65536, 4194304)                                             
                            = -1
  pread64(3 <no return ...>
  error: maximum array length seems negative
  , "", 65536, -65536)                                                          
                            = -1
  __errno_location()                                                            
                            = 22
  __errno_location()                                                            
                            = 22
  strerror(22)                                                                  
                            = "Invalid argument"
  fprintf(0x7f2b0401c680, "%s: %s: %s\n", "out/cmd/tail", "5M", "Invalid 
argument")                         = 35
  close(3)                                                                      
                            = 0
  __cxa_finalize(0x55ba48e1cfd8)                                                
                            = <void>
  +++ exited (status 1) +++
From: =?utf-8?b?0L3QsNCx?= <[email protected]>
Date: Tue, 1 Aug 2023 17:09:11 +0200
Subject: Add splice()/copy_file_range()/sendfile[64]()

Before:
splice(3, 0x7ffd4b66f348, 1, 0)                = -1
copy_file_range(3, 0x7ffd772bbf28, 1, 0)       = -1
sendfile64(1, 3, 0x7ffd772bbf28, 0x400000)     = -1
pread64(3 <no return ...>
error: maximum array length seems negative
, "", 65536, -65536)                           = -1

After:
splice(3, -65536, 1, nil, 4194304, 0b101)      = -1
copy_file_range(3, -65536, 1, nil, 4194304, 0) = -1
sendfile64(1, 3, -65536, 4194304)              = -1
pread64(3 <no return ...>
error: maximum array length seems negative
, "", 65536, -65536)                           = -1
---
 etc/ltrace.conf | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/etc/ltrace.conf b/etc/ltrace.conf
index 855d373..db914cb 100644
--- a/etc/ltrace.conf
+++ b/etc/ltrace.conf
@@ -60,6 +60,12 @@ int open(string,hex(int),octal);		; WARNING: 3rd argument may not be there
 int open64(string,hex(int),octal);		; WARNING: 3rd argument may not be there
 int openat(openat_fd,string,hex(int),octal);	; WARNING: 4th argument may not be there
 int openat64(openat_fd,string,hex(int),octal);	; WARNING: 4th argument may not be there
+long splice(int,llong*,int,llong*,ulong,bin(uint))
+; unistd.h
+long copy_file_range(int,llong*,int,llong*,ulong,bin(uint))
+; sys/sendfile.h
+long sendfile(int,int,long*,ulong)
+long sendfile64(int,int,llong*,ulong)
 
 ; fnmatch.h
 int fnmatch(string, string, int);
From: =?utf-8?b?0L3QsNCx?= <[email protected]>
Date: Tue, 1 Aug 2023 17:30:15 +0200
Subject: __errno_location() returns an int*, not addr

This means that before:
__errno_location() = 0x7f2707f256c0
__errno_location() = 0x7f2707f256c0
__errno_location() = 0x7f2707f256c0

After:
__errno_location() = 0
__errno_location() = 22
__errno_location() = 22

And this __errno_location() is made useful
---
 etc/ltrace.conf | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/etc/ltrace.conf b/etc/ltrace.conf
index db914cb..3d4f5cd 100644
--- a/etc/ltrace.conf
+++ b/etc/ltrace.conf
@@ -52,7 +52,7 @@ addr  dlsym(addr, string);
 int dlclose(addr);
 
 ; errno.h
-addr __errno_location();
+int* __errno_location();
 
 ; fcntl.h
 typedef openat_fd = enum(AT_FDCWD=-100);

Attachment: signature.asc
Description: PGP signature

Reply via email to