Skip to content

Commit

Permalink
Check that logfile exists before trying to register callbacks to avoi…
Browse files Browse the repository at this point in the history
…d crash.
  • Loading branch information
moyix committed Nov 25, 2013
1 parent abf3685 commit bc05059
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions qemu/panda_plugins/syscalls/syscalls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,13 @@ int exec_callback(CPUState *env, target_ulong pc) {
extern "C" {

bool init_plugin(void *self) {
plugin_log = fopen("/scratch/syscalls.txt", "w");
if(!plugin_log) {
fprintf(stderr, "Couldn't open /scratch/syscalls.txt. Abort.\n");
return false;
}
else return true;

// Don't bother if we're not on x86
#if defined(TARGET_I386) || defined(TARGET_ARM)
panda_cb pcb;
Expand All @@ -353,9 +360,6 @@ bool init_plugin(void *self) {
panda_register_callback(self, PANDA_CB_BEFORE_BLOCK_EXEC, pcb);
#endif

plugin_log = fopen("/scratch/syscalls.txt", "w");
if(!plugin_log) return false;
else return true;
}

void uninit_plugin(void *self) {
Expand Down

0 comments on commit bc05059

Please sign in to comment.