jwt_strdup: No more users of this, remove

Signed-off-by: Ben Collins <bcollins@libjwt.io>
This commit is contained in:
Ben Collins 2025-02-12 21:20:34 -05:00
parent 70b92e338f
commit c19aef6805
No known key found for this signature in database
GPG key ID: 5D5A57C7242B22CF
3 changed files with 5 additions and 23 deletions

View file

@ -55,21 +55,6 @@ void __jwt_freemem(void *ptr)
free(ptr);
}
char *jwt_strdup(const char *str)
{
size_t len;
char *result;
len = strlen(str);
result = (char *)jwt_malloc(len + 1);
if (!result)
return NULL; // LCOV_EXCL_LINE
memcpy(result, str, len);
result[len] = '\0';
return result;
}
/* A time-safe strcmp function */
int jwt_strcmp(const char *str1, const char *str2)
{

View file

@ -221,12 +221,6 @@ void *jwt_base64uri_decode(const char *src, int *ret_len);
JWT_NO_EXPORT
int jwt_strcmp(const char *str1, const char *str2);
JWT_NO_EXPORT
char *jwt_strdup(const char *str);
JWT_NO_EXPORT
void jwt_scrub_key(jwt_t *jwt);
JWT_NO_EXPORT
jwt_t *jwt_verify_sig(jwt_t *jwt, const char *head, unsigned int head_len,
const char *sig);

View file

@ -84,9 +84,9 @@ int jwt_parse(jwt_t *jwt, const char *token, unsigned int *len)
{
char_auto *head = NULL;
char *payload, *sig;
int head_len = strlen(token) + 1;
head = jwt_strdup(token);
head = jwt_malloc(head_len);
if (!head) {
// LCOV_EXCL_START
jwt_write_error(jwt, "Error allocating memory");
@ -94,6 +94,9 @@ int jwt_parse(jwt_t *jwt, const char *token, unsigned int *len)
// LCOV_EXCL_STOP
}
/* head_len includes nil */
memcpy(head, token, head_len);
/* Find the components. */
for (payload = head; payload[0] != '.'; payload++) {
if (payload[0] == '\0') {