Skip to content
This repository has been archived by the owner on Nov 5, 2023. It is now read-only.

Commit

Permalink
Add type casts for mg_base64_decode
Browse files Browse the repository at this point in the history
fixes civetweb#1073 but does not change the interface
  • Loading branch information
bel2125 committed May 23, 2022
1 parent afea23a commit 2466497
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/civetweb.c
Original file line number Diff line number Diff line change
Expand Up @@ -8519,7 +8519,7 @@ parse_auth_header(struct mg_connection *conn,
const char *userpw_b64 = auth_header + 6;
size_t userpw_b64_len = strlen(userpw_b64);
size_t buf_len_r = buf_size;
if (mg_base64_decode(userpw_b64, userpw_b64_len, buf, &buf_len_r)
if (mg_base64_decode(userpw_b64, userpw_b64_len, (unsigned char *)buf, &buf_len_r)
!= -1) {
return 0; /* decode error */
}
Expand Down
8 changes: 4 additions & 4 deletions unittest/public_func.c
Original file line number Diff line number Diff line change
Expand Up @@ -589,23 +589,23 @@ START_TEST(test_mg_base64)

memset(buf, 77, sizeof(buf));
len = 9999;
mg_base64_encode((unsigned char *)alpha, (int)strlen(alpha), buf, &len);
mg_base64_encode((unsigned char *)alpha, strlen(alpha), buf, &len);
ck_assert_str_eq(buf, alpha_b64_enc);
ck_assert_int_eq((int)len, (int)strlen(alpha_b64_enc) + 1);

memset(buf, 77, sizeof(buf));
len = 9999;
mg_base64_encode((unsigned char *)nonalpha,
(int)strlen(nonalpha),
(unsigned char *)buf,
strlen(nonalpha),
(char *)buf,
&len);
ck_assert_str_eq(buf, nonalpha_b64_enc);
ck_assert_int_eq((int)len, (int)strlen(nonalpha_b64_enc) + 1);

memset(buf, 77, sizeof(buf));
len = 9999;
ret = mg_base64_decode((char *)alpha_b64_enc,
(int)strlen(alpha_b64_enc),
strlen(alpha_b64_enc),
(unsigned char *)buf,
&len);
ck_assert_int_eq(ret, -1);
Expand Down

0 comments on commit 2466497

Please sign in to comment.