Skip to content

Commit 1ff9572

Browse files
committed
Fix utils not detecting symbols and add strtok_r
While adding HAVE_STRTOK_R I noticed utils.c was not including config.h, which also made the HAVE_STRNCPY test fail, so fix it.
1 parent 67b1083 commit 1ff9572

File tree

6 files changed

+18
-4
lines changed

6 files changed

+18
-4
lines changed

kubernetes/ConfigureChecks.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ include(CheckSymbolExists)
33
check_symbol_exists(strndup "string.h" HAVE_STRNDUP)
44
check_symbol_exists(secure_getenv "stdlib.h" HAVE_SECURE_GETENV)
55
check_symbol_exists(getenv "stdlib.h" HAVE_GETENV)
6+
check_symbol_exists(strtok_r "string.h" HAVE_STRTOK_R)

kubernetes/config.h.in

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
#cmakedefine HAVE_STRNDUP
22
#cmakedefine HAVE_SECURE_GETENV
3-
#cmakedefine HAVE_GETENV
3+
#cmakedefine HAVE_GETENV
4+
#cmakedefine HAVE_STRTOK_R

kubernetes/config/authn_plugin/plugins/oidc/libkubernetes_oidc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
static time_t get_token_expiration_time(const char *token_string)
3030
{
3131
static char fname[] = "get_token_expiration_time()";
32-
char *last;
3332

3433
time_t expiration_time = 0;
3534

@@ -42,6 +41,7 @@ static time_t get_token_expiration_time(const char *token_string)
4241
}
4342

4443
char *p = NULL;
44+
char *last = NULL;
4545
p = strtok_r(dup_token_string, OIDC_ID_TOKEN_DELIM, &last); /* jwt header */
4646
if (!p) {
4747
fprintf(stderr, "%s: The token <%s> is not a valid JWT token.\n", fname, token_string);

kubernetes/include/utils.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ extern "C" {
99
char *strndup(const char *s, size_t n);
1010
#endif /* ! HAVE_STRNDUP */
1111

12+
#if !defined(HAVE_STRTOK_R)
13+
char *strtok_r(char *str, const char *delim, char **saveptr);
14+
#endif /* ! HAVE_STRTOK_R */
15+
1216
#ifdef __cplusplus
1317
}
1418
#endif

kubernetes/src/utils.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#include <stdlib.h>
22
#include "../include/utils.h"
33
#include <string.h>
4+
#include "config.h"
45

56
// based on https://github.com/libssh/libssh-mirror/commit/247983e9820fd264cb5a59c14cc12846c028bd08#diff-744295d01685fa411dbfd78679ea20b51dfa4ac7d2d722df53f3d86d728493f8
67
#if !defined(HAVE_STRNDUP)
@@ -22,4 +23,11 @@ char *strndup(const char *s, size_t n)
2223

2324
return x;
2425
}
25-
#endif /* ! HAVE_STRNDUP */
26+
#endif /* ! HAVE_STRNDUP */
27+
28+
#if !defined(HAVE_STRTOK_R)
29+
char *strtok_r(char *str, const char *delim, char **saveptr)
30+
{
31+
return strtok(str, delim);
32+
}
33+
#endif /* ! HAVE_STRTOK_R */

kubernetes/watch/watch_util.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
static int wu_convert_to_json_array(list_t * json_array, const char *json_string)
1212
{
13-
char *last;
13+
char *last = NULL;
1414

1515
if (!json_string || '\0' == json_string[0] || !json_array) {
1616
return -1;

0 commit comments

Comments
 (0)