aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYour Name <you@example.com>2021-04-16 07:06:37 +0100
committerYour Name <you@example.com>2021-04-16 10:17:43 +0100
commit950648c513d031b5c829565255a7c157a33ba7c3 (patch)
treed0ec8d2b2bc972092de0595b415d02a6720e4b2b
parente41d1183cca02fb4d6398df4fc3e028dfd9c5f72 (diff)
downloadafl++-950648c513d031b5c829565255a7c157a33ba7c3.tar.gz
Changes following code review
-rw-r--r--frida_mode/src/instrument.c8
-rw-r--r--frida_mode/src/ranges.c3
-rw-r--r--frida_mode/test/testinstr.c7
3 files changed, 15 insertions, 3 deletions
diff --git a/frida_mode/src/instrument.c b/frida_mode/src/instrument.c
index 042fdab8..22910062 100644
--- a/frida_mode/src/instrument.c
+++ b/frida_mode/src/instrument.c
@@ -174,7 +174,13 @@ void instrument_coverage_optimize(const cs_insn * instr,
static void on_basic_block(GumCpuContext *context, gpointer user_data) {
- /* Avoid stack operations in potentially performance critical code */
+ /*
+ * This function is performance critical as it is called to instrument every
+ * basic block. By moving our print buffer to a global, we avoid it affecting
+ * the critical path with additional stack adjustments if tracing is not
+ * enabled. If tracing is enabled, then we're printing a load of diagnostic
+ * information so this overhead is unlikely to be noticeable.
+ */
static char buffer[200];
int len;
guint64 current_pc = (guint64)user_data;
diff --git a/frida_mode/src/ranges.c b/frida_mode/src/ranges.c
index fc14710f..49ef5a62 100644
--- a/frida_mode/src/ranges.c
+++ b/frida_mode/src/ranges.c
@@ -29,8 +29,7 @@ static void convert_address_token(gchar *token, GumMemoryRange *range) {
gchar **tokens;
int token_count;
tokens = g_strsplit(token, "-", 2);
- for (token_count = 0; tokens[token_count] != NULL; token_count++)
- ;
+ for (token_count = 0; tokens[token_count] != NULL; token_count++) {}
if (token_count != 2) {
diff --git a/frida_mode/test/testinstr.c b/frida_mode/test/testinstr.c
index 2c3d5144..37d47f91 100644
--- a/frida_mode/test/testinstr.c
+++ b/frida_mode/test/testinstr.c
@@ -78,6 +78,13 @@ int main(int argc, char **argv) {
}
buf = malloc(len);
+ if (buf == NULL) {
+
+ perror("malloc");
+ break;
+
+ }
+
n_read = read(fd, buf, len);
if (n_read != len) {