Increase buffer size

This commit is contained in:
Hui Yu
2023-03-24 20:36:56 +08:00
parent 859fc3f5ee
commit 20d4ad12a6
3 changed files with 9 additions and 5 deletions

View File

@@ -5,9 +5,9 @@
#include <errno.h>
#define ARGS_DELIM " "
#define KUBECONFIG_EXEC_ARGS_BUFFER_SIZE 1024
#define KUBECONFIG_EXEC_COMMAND_BUFFER_SIZE 1024
#define KUBECONFIG_STRING_BUFFER_SIZE 1024
#define KUBECONFIG_EXEC_ARGS_BUFFER_SIZE 4096
#define KUBECONFIG_EXEC_COMMAND_BUFFER_SIZE 4096
#define KUBECONFIG_STRING_BUFFER_SIZE 4096
#define KUBECONFIG_EXEC_RESULT_BUFFER_SIZE 4096
int kube_exec_and_get_result(ExecCredential_t * exec_credential, const kubeconfig_property_t * exec)

View File

@@ -93,6 +93,10 @@ static int setApiKeys(list_t ** pApiKeys, const char *token)
return -1;
}
if (strlen(BEARER_TOKEN_TEMPLATE) + strlen(token) >= BEARER_TOKEN_BUFFER_SIZE) {
fprintf(stderr, "%s: The buffer for bearer token is insufficient.\n", fname);
return -1;
}
char tokenValue[BEARER_TOKEN_BUFFER_SIZE];
memset(tokenValue, 0, sizeof(tokenValue));
snprintf(tokenValue, BEARER_TOKEN_BUFFER_SIZE, BEARER_TOKEN_TEMPLATE, token);

View File

@@ -7,7 +7,7 @@ extern "C" {
#define AUTH_TOKEN_KEY "Authorization"
#define BEARER_TOKEN_TEMPLATE "Bearer %s"
#define BEARER_TOKEN_BUFFER_SIZE 2048
#define BEARER_TOKEN_BUFFER_SIZE 4096
#define BASIC_TOKEN_TEMPLATE "Basic %s"
#define BASIC_TOKEN_BUFFER_SIZE 1024