Skip to content

Commit

Permalink
Correct BPF bindings error
Browse files Browse the repository at this point in the history
  • Loading branch information
Roeegg2 committed Dec 11, 2024
1 parent d2e0e92 commit 7dfbe55
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
5 changes: 3 additions & 2 deletions arch/BPF/BPFInstPrinter.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include "BPFConstants.h"
#include "BPFInstPrinter.h"
#include "BPFMapping.h"
#include "../../Mapping.h"

static cs_bpf_op *expand_bpf_operands(cs_bpf *bpf)
{
Expand Down Expand Up @@ -348,7 +349,7 @@ static void print_operand(MCInst *MI, struct SStream *O, const cs_bpf_op *op)
* */
void BPF_printInst(MCInst *MI, struct SStream *O, void *PrinterInfo)
{
cs_bpf bpf;
cs_bpf bpf = { 0 };

/* set pubOpcode as instruction id */
SStream_concat(O, BPF_insn_name((csh)MI->csh, MCInst_getOpcodePub(MI)));
Expand All @@ -362,7 +363,7 @@ void BPF_printInst(MCInst *MI, struct SStream *O, void *PrinterInfo)
}

#ifndef CAPSTONE_DIET
if (MI->flat_insn->detail) {
if (detail_is_set(MI)) {
MI->flat_insn->detail->bpf = bpf;
}
#endif
Expand Down
6 changes: 3 additions & 3 deletions bindings/python/capstone/bpf.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@

class BPFOpMem(ctypes.Structure):
_fields_ = (
('base', ctypes.c_uint8),
('base', ctypes.c_int),
('disp', ctypes.c_int32),
)

class BPFOpValue(ctypes.Union):
_fields_ = (
('reg', ctypes.c_uint8),
('reg', ctypes.c_int),
('imm', ctypes.c_uint64),
('off', ctypes.c_uint32),
('mem', BPFOpMem),
Expand All @@ -26,9 +26,9 @@ class BPFOp(ctypes.Structure):
_fields_ = (
('type', ctypes.c_uint),
('value', BPFOpValue),
('access', ctypes.c_uint8),
('is_signed', ctypes.c_bool),
('is_pkt', ctypes.c_bool),
('access', ctypes.c_uint8),
)

@property
Expand Down
2 changes: 1 addition & 1 deletion suite/cstest/src/test_detail_bpf.c
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// Copyright © 2024 Rot127 <[email protected]>
// SPDX-License-Identifier: BSD-3

#include "capstone/bpf.h"
#include "test_compare.h"
#include "test_detail_bpf.h"
#include <capstone/bpf.h>
#include <capstone/capstone.h>
#include <stdio.h>
#include <string.h>
Expand Down

0 comments on commit 7dfbe55

Please sign in to comment.