Skip to content
Closed

Fix#1 #1134

Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 22 additions & 13 deletions tools/bpf/bpf_jit_disasm.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,28 @@

static void get_exec_path(char *tpath, size_t size)
{
char *path;
ssize_t len;

snprintf(tpath, size, "/proc/%d/exe", (int) getpid());
tpath[size - 1] = 0;

path = strdup(tpath);
assert(path);

len = readlink(path, tpath, size);
tpath[len] = 0;

free(path);
char *path;
ssize_t len;

snprintf(tpath, size, "/proc/%d/exe", (int)getpid());
tpath[size - 1] = 0;

path = strdup(tpath);
assert(path);

len = readlink(path, tpath, size);
if (len < 0) {
perror("readlink failed");
free(path);
return;
}
if ((size_t)len < size) {
tpath[len] = 0;
} else {
tpath[size - 1] = 0;
}

free(path);
}

static void get_asm_insns(uint8_t *image, size_t len, int opcodes)
Expand Down