Skip to content

Commit ab31f40

Browse files
authored
Merge pull request #178 from ityuhui/yh-enlarge-buffer-0324
Increase buffer size
2 parents 859fc3f + 20d4ad1 commit ab31f40

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed

kubernetes/config/exec_provider.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
#include <errno.h>
66

77
#define ARGS_DELIM " "
8-
#define KUBECONFIG_EXEC_ARGS_BUFFER_SIZE 1024
9-
#define KUBECONFIG_EXEC_COMMAND_BUFFER_SIZE 1024
10-
#define KUBECONFIG_STRING_BUFFER_SIZE 1024
8+
#define KUBECONFIG_EXEC_ARGS_BUFFER_SIZE 4096
9+
#define KUBECONFIG_EXEC_COMMAND_BUFFER_SIZE 4096
10+
#define KUBECONFIG_STRING_BUFFER_SIZE 4096
1111
#define KUBECONFIG_EXEC_RESULT_BUFFER_SIZE 4096
1212

1313
int kube_exec_and_get_result(ExecCredential_t * exec_credential, const kubeconfig_property_t * exec)
@@ -69,7 +69,7 @@ int kube_exec_and_get_result(ExecCredential_t * exec_credential, const kubeconfi
6969
#ifndef _WIN32
7070
fp = popen(command_string, "r"); /* r means read from stdout */
7171
#else
72-
fp = _popen(command_string, "r"); /* r means read from stdout */
72+
fp = _popen(command_string, "r"); /* r means read from stdout */
7373
#endif
7474
if (fp) {
7575
result_string = calloc(1, KUBECONFIG_EXEC_RESULT_BUFFER_SIZE);

kubernetes/config/kube_config.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,10 @@ static int setApiKeys(list_t ** pApiKeys, const char *token)
9393
return -1;
9494
}
9595

96+
if (strlen(BEARER_TOKEN_TEMPLATE) + strlen(token) >= BEARER_TOKEN_BUFFER_SIZE) {
97+
fprintf(stderr, "%s: The buffer for bearer token is insufficient.\n", fname);
98+
return -1;
99+
}
96100
char tokenValue[BEARER_TOKEN_BUFFER_SIZE];
97101
memset(tokenValue, 0, sizeof(tokenValue));
98102
snprintf(tokenValue, BEARER_TOKEN_BUFFER_SIZE, BEARER_TOKEN_TEMPLATE, token);

kubernetes/config/kube_config_common.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ extern "C" {
77

88
#define AUTH_TOKEN_KEY "Authorization"
99
#define BEARER_TOKEN_TEMPLATE "Bearer %s"
10-
#define BEARER_TOKEN_BUFFER_SIZE 2048
10+
#define BEARER_TOKEN_BUFFER_SIZE 4096
1111
#define BASIC_TOKEN_TEMPLATE "Basic %s"
1212
#define BASIC_TOKEN_BUFFER_SIZE 1024
1313

0 commit comments

Comments
 (0)