From 5f455b13259a111b4128ad2a8e3e8c350b0de1a3 Mon Sep 17 00:00:00 2001 From: Steve Sperandeo Date: Tue, 5 Mar 2024 21:07:12 +0000 Subject: [PATCH] Fixed pod logs core api request errors. --- kubernetes/api/CoreV1API.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/kubernetes/api/CoreV1API.c b/kubernetes/api/CoreV1API.c index deadb92b..7d8c0fc5 100644 --- a/kubernetes/api/CoreV1API.c +++ b/kubernetes/api/CoreV1API.c @@ -35170,7 +35170,7 @@ CoreV1API_readNamespacedPodLog(apiClient_t *apiClient, char *name, char *_namesp keyPairQuery_timestamps = keyValuePair_create(keyQuery_timestamps, valueQuery_timestamps); list_addElement(localVarQueryParameters,keyPairQuery_timestamps); } - list_addElement(localVarHeaderType,"text/plain"); //produces + //list_addElement(localVarHeaderType,"text/plain"); //produces removed text/plain as it is rejected list_addElement(localVarHeaderType,"application/json"); //produces list_addElement(localVarHeaderType,"application/yaml"); //produces list_addElement(localVarHeaderType,"application/vnd.kubernetes.protobuf"); //produces @@ -35193,9 +35193,11 @@ CoreV1API_readNamespacedPodLog(apiClient_t *apiClient, char *name, char *_namesp // printf("%s\n","Unauthorized"); //} //primitive return type simple - char* elementToReturn = strdup((char*)apiClient->dataReceived); + char* elementToReturn = NULL; if (apiClient->dataReceived) { + // moved strdup inside the guard to prevent segfaults on NULL dataReceived + elementToReturn = strdup((char*)apiClient->dataReceived); free(apiClient->dataReceived); apiClient->dataReceived = NULL; apiClient->dataReceivedLen = 0;