git: 1663c003bcb6 - main - sysutils/scanmem: use correct types for parameters in ptrace(2) calls
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Tue, 14 Feb 2023 03:31:55 UTC
The branch main has been updated by danfe: URL: https://cgit.FreeBSD.org/ports/commit/?id=1663c003bcb6fbc65e71ed67e87dc4bd9a04d724 commit 1663c003bcb6fbc65e71ed67e87dc4bd9a04d724 Author: Alexey Dokuchaev <danfe@FreeBSD.org> AuthorDate: 2023-02-14 03:31:04 +0000 Commit: Alexey Dokuchaev <danfe@FreeBSD.org> CommitDate: 2023-02-14 03:31:04 +0000 sysutils/scanmem: use correct types for parameters in ptrace(2) calls Clang 15 is now very strict about these bugs and would no longer accept such broken code. Reported by: pkg-fallout --- sysutils/scanmem/files/patch-ptrace.c | 45 +++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/sysutils/scanmem/files/patch-ptrace.c b/sysutils/scanmem/files/patch-ptrace.c index b22f53a6a2ea..da80b94b2113 100644 --- a/sysutils/scanmem/files/patch-ptrace.c +++ b/sysutils/scanmem/files/patch-ptrace.c @@ -14,6 +14,42 @@ #include <time.h> #include <sys/types.h> +@@ -94,7 +96,7 @@ bool sm_attach(pid_t target) + int status; + + /* attach to the target application, which should cause a SIGSTOP */ +- if (ptrace(PTRACE_ATTACH, target, NULL, NULL) == -1L) { ++ if (ptrace(PTRACE_ATTACH, target, NULL, 0) == -1L) { + show_error("failed to attach to %d, %s\n", target, strerror(errno)); + return false; + } +@@ -117,7 +119,7 @@ bool sm_attach(pid_t target) + bool sm_detach(pid_t target) + { + // addr is ignored on Linux, but should be 1 on FreeBSD in order to let the child process continue execution where it had been interrupted +- return ptrace(PTRACE_DETACH, target, 1, 0) == 0; ++ return ptrace(PTRACE_DETACH, target, (caddr_t)1, 0) == 0; + } + + +@@ -184,7 +186,7 @@ extern inline bool sm_peekdata(pid_t pid, const void * + for (i = 0; i < missing_bytes; i += sizeof(long)) + { + const char *ptrace_address = peekbuf.base + peekbuf.size; +- long ptraced_long = ptrace(PTRACE_PEEKDATA, pid, ptrace_address, NULL); ++ long ptraced_long = ptrace(PTRACE_PEEKDATA, pid, ptrace_address, 0); + + /* check if ptrace() succeeded */ + if (EXPECT(ptraced_long == -1L && errno != 0, false)) { +@@ -195,7 +197,7 @@ extern inline bool sm_peekdata(pid_t pid, const void * + for (j = 1, errno = 0; j < sizeof(long); j++, errno = 0) { + + /* try for a shifted ptrace - 'continue' (i.e. try an increased shift) if it fails */ +- if ((ptraced_long = ptrace(PTRACE_PEEKDATA, pid, ptrace_address - j, NULL)) == -1L && ++ if ((ptraced_long = ptrace(PTRACE_PEEKDATA, pid, ptrace_address - j, 0)) == -1L && + (errno == EIO || errno == EFAULT)) + continue; + @@ -406,7 +408,7 @@ bool sm_checkmatches(globals_t *vars, return sm_detach(vars->target); } @@ -50,3 +86,12 @@ bool sm_write_array(pid_t target, void *addr, const void *data, int len) { int i,j; +@@ -735,7 +737,7 @@ bool sm_write_array(pid_t target, void *addr, const vo + for(j = 0; j <= sizeof(long) - (len - i); ++j) + { + errno = 0; +- if(((peek_value = ptrace(PTRACE_PEEKDATA, target, addr - j, NULL)) == -1L) && (errno != 0)) ++ if(((peek_value = ptrace(PTRACE_PEEKDATA, target, addr - j, 0)) == -1L) && (errno != 0)) + { + if (errno == EIO || errno == EFAULT) /* may try next shift */ + continue;