Skip to content

Commit

Permalink
Merge pull request #1296 from rich-coe/bug.1291
Browse files Browse the repository at this point in the history
(#1291)  null terminate the received data
  • Loading branch information
lwindolf authored Aug 26, 2023
2 parents 9860146 + 36f5264 commit 0874224
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/net.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,18 @@ network_process_callback (GObject *obj, GAsyncResult *res, gpointer user_data)
gboolean revalidated = FALSE;
gint maxage;
gint age;
gint body_size;
g_autoptr(GBytes) body;

msg = soup_session_get_async_result_message (session, res);
body = soup_session_send_and_read_finish (session, res, NULL); // FIXME: handle errors!

job->result->source = g_uri_to_string_partial (soup_message_get_uri (msg), 0);
job->result->httpstatus = soup_message_get_status (msg);
job->result->data = g_memdup2 (g_bytes_get_data (body, &job->result->size), g_bytes_get_size (body));
body_size = g_bytes_get_size (body);
job->result->data = g_malloc(1 + body_size);
memmove(job->result->data, g_bytes_get_data (body, &job->result->size), body_size);
*(job->result->data + job->result->size) = 0;

/* keep some request headers for revalidated responses */
revalidated = (304 == job->result->httpstatus);
Expand Down

0 comments on commit 0874224

Please sign in to comment.