Skip to content

Commit

Permalink
Use qio_channel api
Browse files Browse the repository at this point in the history
  • Loading branch information
rmalmain committed May 3, 2024
1 parent 7e3d3b4 commit f0ac33a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
11 changes: 6 additions & 5 deletions io/channel-buffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ qio_channel_buffer_new(size_t capacity)
if (capacity) {
ioc->data = g_new0(uint8_t, capacity);
ioc->capacity = capacity;

//// --- Begin LibAFL code ---
ioc->internal_allocation = true;
//// --- End LibAFL code ---
}

//// --- Begin LibAFL code ---
ioc->internal_allocation = capacity > 0;
//// --- End LibAFL code ---

return ioc;
}

Expand Down Expand Up @@ -75,6 +75,7 @@ static void qio_channel_buffer_finalize(Object *obj)
g_free(ioc->data);
}

ioc->data = NULL;
//// --- End LibAFL code ---
// g_free(ioc->data);

Expand Down Expand Up @@ -181,8 +182,8 @@ static int qio_channel_buffer_close(QIOChannel *ioc,
g_free(bioc->data);
}

//g_free(bioc->data);
//// --- End LibAFL code ---
//g_free(bioc->data);
bioc->data = NULL;
bioc->capacity = bioc->usage = bioc->offset = 0;

Expand Down
6 changes: 5 additions & 1 deletion libafl/syx-snapshot/device-save.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ DeviceSaveState* device_save_kind(DeviceSnapshotKind kind, char** names) {
}

void device_restore_all(DeviceSaveState* dss) {
Error* err = NULL;

assert(dss->save_buffer != NULL);

QIOChannelBuffer* bioc = qio_channel_buffer_new_external(dss->save_buffer, QEMU_FILE_RAM_LIMIT, dss->save_buffer_size);
Expand All @@ -99,7 +101,9 @@ void device_restore_all(DeviceSaveState* dss) {

libafl_restoring_devices = save_libafl_restoring_devices;

object_unref(OBJECT(bioc));
qio_channel_close(ioc, &err);
assert(!err);

qemu_fclose(f);
}

Expand Down

0 comments on commit f0ac33a

Please sign in to comment.