Changeset View
Changeset View
Standalone View
Standalone View
security/py-angr/files/patch-native_log.c
- This file was added.
Property | Old Value | New Value |
---|---|---|
fbsd:nokeywords | null | yes \ No newline at end of property |
svn:eol-style | null | native \ No newline at end of property |
svn:keywords | null | FreeBSD=%H \ No newline at end of property |
svn:mime-type | null | text/plain \ No newline at end of property |
--- native/log.c.orig 2020-03-02 23:36:13 UTC | |||||
+++ native/log.c | |||||
@@ -34,6 +34,9 @@ | |||||
#include <unistd.h> | |||||
#include <sys/syscall.h> | |||||
+#ifdef __FreeBSD__ | |||||
+#include <sys/thr.h> | |||||
+#endif | |||||
static int log_fd = STDERR_FILENO; | |||||
static bool log_fd_isatty = true; | |||||
@@ -107,7 +110,14 @@ void logLog(enum llevel_t ll, const char *fn, int ln, | |||||
dprintf(log_fd, "%s", logLevels[ll].prefix); | |||||
} | |||||
if (logLevels[ll].print_funcline) { | |||||
+#ifdef __FreeBSD__ | |||||
0mp: This is the part which I am not sure about. | |||||
+ pid_t tid = 0; | |||||
+ // XXX: No error handling. | |||||
+ syscall(SYS_thr_self, &tid); | |||||
Done Inline ActionsThere is no reason to zero errno here. kaktus: There is no reason to zero errno here. | |||||
+ dprintf(log_fd, "[%s][%s][%d] %s():%d ", timestr, logLevels[ll].descr, (pid_t)tid, fn, ln); | |||||
+#else | |||||
dprintf(log_fd, "[%s][%s][%d] %s():%d ", timestr, logLevels[ll].descr, (pid_t)syscall(__NR_gettid), fn, ln); | |||||
Done Inline Actionsif (thr_self(&tid) <0 )… or maybe just (if it links with pthreads) dprintf(log_fd, "[%s][%s][%d] %s():%d ", timestr, logLevels[ll].descr, pthread_getthreadid_np(), fn, ln); kaktus: ```
if (thr_self(&tid) <0 )…
```
or maybe just (if it links with pthreads)
```
dprintf(log_fd… | |||||
Done Inline ActionsI'll try it out soon. 0mp: I'll try it out soon. | |||||
Done Inline ActionsYeah, seems to compile. 0mp: Yeah, seems to compile. | |||||
+#endif | |||||
Done Inline Actionstid is already of type pid_t, no reason to cast it to pid_t again. kaktus: tid is already of type pid_t, no reason to cast it to pid_t again. | |||||
} | |||||
va_list args; |
This is the part which I am not sure about.