summaryrefslogtreecommitdiff
path: root/security/tct/patches/patch-am
blob: 1dad734b220336f02d327c48448fc7930e4c9761 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
$NetBSD: patch-am,v 1.3 2015/03/19 08:34:53 dholland Exp $

 - Use standard headers.
 - Support NetBSD.
 - LP64 fix.

--- src/pcat/pcat.c.orig	2001-09-25 17:22:20.000000000 +0000
+++ src/pcat/pcat.c
@@ -75,6 +75,7 @@
 
 #include <stdio.h>
 #include <stdlib.h>
+#include <string.h>
 #include <unistd.h>
 #include <fcntl.h>
 #include <signal.h>
@@ -177,6 +178,24 @@
 #endif
 
  /*
+  * Based on the OpenBSD code above.
+  */
+#if defined(NETBSD1) || defined(NETBSD2)
+#define SUPPORTED
+#include <sys/param.h>
+#include <sys/user.h>
+#include <sys/sysctl.h>
+#include <kvm.h>
+#include <stddef.h>
+#define HAVE_PTRACE_MEM
+#define PTRACE_ATTACH	PT_ATTACH
+#define PTRACE_DETACH	PT_DETACH
+#define PTRACE_PEEKDATA	PT_READ_D
+#define HAVE_BROKEN_CTOB
+#define PTRACE_ARG3_T	caddr_t
+#endif
+
+ /*
   * SunOS 4.x has no /proc, and ptrace() peeking the u area won't give us the
   * process memory segment sizes. Instead we must grope process information
   * from kernel virtual memory. This requires super-user privilege.
@@ -414,7 +433,7 @@ static int ptrace_attach_wait(pid_t pid)
 
 /* call_ptrace - ptrace() with error handling */
 
-static int call_ptrace(int request, pid_t pid, int addr, int data)
+static int call_ptrace(int request, pid_t pid, uintptr_t addr, int data)
 {
     int     result;
 
@@ -456,7 +475,7 @@ static void read_proc(PROC_INFO *proc, c
 	      "; did you use GCC with another machine's header files?" : "");
 #else
     int     words[READ_BUFSIZ_WORDS];
-    int     addr;
+    uintptr_t     addr;
     int     n;
 
     /*
@@ -469,7 +488,7 @@ static void read_proc(PROC_INFO *proc, c
 	panic("read_proc: request size %d is not word-aligned", len);
     if (verbose)
 	fprintf(stderr, "read seek to 0x%lx\n", (long) offset);
-    for (n = 0, addr = (int) offset; n < len / sizeof(int); addr += sizeof(int), n++)
+    for (n = 0, addr = (uintptr_t) offset; n < len / sizeof(int); addr += sizeof(int), n++)
 	words[n] = call_ptrace(PTRACE_PEEKDATA, proc->pid, addr, 0);
     memcpy(data, (char *) words, len);
 #endif