From e0a720481c8643efff7fb16e29ffc9f7c734a4f7 Mon Sep 17 00:00:00 2001
From: Adam Williamson <awilliam@redhat.com>
Date: Tue, 30 Aug 2022 10:59:01 -0700
Subject: [PATCH 2/2] Handle some potential problems in parsing oauth2 access
tokens
It's possible for `_rest_proxy_send_message` to return `NULL`,
which would mean the `payload` here would be `NULL`. If so,
we're not going to be able to do anything, so we should just
bail out.
Signed-off-by: Adam Williamson <awilliam@redhat.com>
---
rest/rest-oauth2-proxy.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/rest/rest-oauth2-proxy.c b/rest/rest-oauth2-proxy.c
index 9511f97..dd87bd9 100644
--- a/rest/rest-oauth2-proxy.c
+++ b/rest/rest-oauth2-proxy.c
@@ -70,6 +70,11 @@ rest_oauth2_proxy_parse_access_token (RestOAuth2Proxy *self,
gint created_at;
g_return_if_fail (REST_IS_OAUTH2_PROXY (self));
+ if (!payload)
+ {
+ g_task_return_new_error (task, G_IO_ERROR, G_IO_ERROR_FAILED, "Empty payload");
+ return;
+ }
data = g_bytes_get_data (payload, &size);
--
2.44.0