mirror of
https://dev.iopsys.eu/feed/iopsys.git
synced 2025-12-10 07:44:50 +01:00
libstrophe: rename base64_decode/encode functions
This commit is contained in:
parent
6b51f9d01f
commit
d2309a5330
1 changed files with 221 additions and 0 deletions
221
libstrophe/patches/100-rename_base64_functions.patch
Normal file
221
libstrophe/patches/100-rename_base64_functions.patch
Normal file
|
|
@ -0,0 +1,221 @@
|
|||
diff --git a/src/auth.c b/src/auth.c
|
||||
index b3056a2..2673bdf 100644
|
||||
--- a/src/auth.c
|
||||
+++ b/src/auth.c
|
||||
@@ -455,7 +455,7 @@ static int _handle_scram_sha1_challenge(xmpp_conn_t * const conn,
|
||||
if (!text)
|
||||
goto err;
|
||||
|
||||
- challenge = (char *)base64_decode(conn->ctx, text, strlen(text));
|
||||
+ challenge = (char *)strophe_base64_decode(conn->ctx, text, strlen(text));
|
||||
xmpp_free(conn->ctx, text);
|
||||
if (!challenge)
|
||||
goto err;
|
||||
@@ -515,7 +515,7 @@ static char *_get_nonce(xmpp_ctx_t *ctx)
|
||||
*(time_t *)(buffer + sizeof(clock_t)) = (time_t)rand();
|
||||
}
|
||||
|
||||
- return base64_encode(ctx, buffer, sizeof(buffer));
|
||||
+ return strophe_base64_encode(ctx, buffer, sizeof(buffer));
|
||||
}
|
||||
|
||||
static char *_make_scram_sha1_init_msg(xmpp_conn_t * const conn)
|
||||
@@ -662,7 +662,7 @@ static void _auth(xmpp_conn_t * const conn)
|
||||
return;
|
||||
}
|
||||
|
||||
- str = (char *)base64_encode(conn->ctx, (unsigned char *)scram_init,
|
||||
+ str = (char *)strophe_base64_encode(conn->ctx, (unsigned char *)scram_init,
|
||||
strlen(scram_init));
|
||||
if (!str) {
|
||||
xmpp_free(conn->ctx, scram_init);
|
||||
diff --git a/src/sasl.c b/src/sasl.c
|
||||
index 3d83fd0..b6f2b89 100644
|
||||
--- a/src/sasl.c
|
||||
+++ b/src/sasl.c
|
||||
@@ -46,7 +46,7 @@ char *sasl_plain(xmpp_ctx_t *ctx, const char *authid, const char *password) {
|
||||
memcpy(msg+1, authid, idlen);
|
||||
msg[1+idlen] = '\0';
|
||||
memcpy(msg+1+idlen+1, password, passlen);
|
||||
- result = base64_encode(ctx, (unsigned char *)msg, 2 + idlen + passlen);
|
||||
+ result = strophe_base64_encode(ctx, (unsigned char *)msg, 2 + idlen + passlen);
|
||||
xmpp_free(ctx, msg);
|
||||
}
|
||||
|
||||
@@ -92,7 +92,7 @@ static hash_t *_parse_digest_challenge(xmpp_ctx_t *ctx, const char *msg)
|
||||
char *key, *value;
|
||||
unsigned char *s, *t;
|
||||
|
||||
- text = base64_decode(ctx, msg, strlen(msg));
|
||||
+ text = strophe_base64_decode(ctx, msg, strlen(msg));
|
||||
if (text == NULL) {
|
||||
xmpp_error(ctx, "SASL", "couldn't Base64 decode challenge!");
|
||||
return NULL;
|
||||
@@ -344,7 +344,7 @@ char *sasl_digest_md5(xmpp_ctx_t *ctx, const char *challenge,
|
||||
hash_release(table); /* also frees value strings */
|
||||
|
||||
/* reuse response for the base64 encode of our result */
|
||||
- response = base64_encode(ctx, (unsigned char *)result, strlen(result));
|
||||
+ response = strophe_base64_encode(ctx, (unsigned char *)result, strlen(result));
|
||||
xmpp_free(ctx, result);
|
||||
|
||||
return response;
|
||||
@@ -396,7 +396,7 @@ char *sasl_scram_sha1(xmpp_ctx_t *ctx, const char *challenge,
|
||||
goto out;
|
||||
}
|
||||
|
||||
- sval = (char *)base64_decode(ctx, s, strlen(s));
|
||||
+ sval = (char *)strophe_base64_decode(ctx, s, strlen(s));
|
||||
if (!sval) {
|
||||
goto out;
|
||||
}
|
||||
@@ -426,7 +426,7 @@ char *sasl_scram_sha1(xmpp_ctx_t *ctx, const char *challenge,
|
||||
sign[j] ^= key[j];
|
||||
}
|
||||
|
||||
- sign_b64 = base64_encode(ctx, sign, sizeof(sign));
|
||||
+ sign_b64 = strophe_base64_encode(ctx, sign, sizeof(sign));
|
||||
if (!sign_b64) {
|
||||
goto out_response;
|
||||
}
|
||||
@@ -439,7 +439,7 @@ char *sasl_scram_sha1(xmpp_ctx_t *ctx, const char *challenge,
|
||||
strcat(response, sign_b64);
|
||||
xmpp_free(ctx, sign_b64);
|
||||
|
||||
- response_b64 = base64_encode(ctx, (unsigned char *)response,
|
||||
+ response_b64 = strophe_base64_encode(ctx, (unsigned char *)response,
|
||||
strlen(response));
|
||||
if (!response_b64) {
|
||||
goto out_response;
|
||||
@@ -501,7 +501,7 @@ int base64_encoded_len(xmpp_ctx_t *ctx, const unsigned len)
|
||||
return ((len + 2)/3) << 2;
|
||||
}
|
||||
|
||||
-char *base64_encode(xmpp_ctx_t *ctx,
|
||||
+char *strophe_base64_encode(xmpp_ctx_t *ctx,
|
||||
const unsigned char * const buffer, const unsigned len)
|
||||
{
|
||||
int clen;
|
||||
@@ -579,7 +579,7 @@ int base64_decoded_len(xmpp_ctx_t *ctx,
|
||||
return 3 * (len >> 2) - nudge;
|
||||
}
|
||||
|
||||
-unsigned char *base64_decode(xmpp_ctx_t *ctx,
|
||||
+unsigned char *strophe_base64_decode(xmpp_ctx_t *ctx,
|
||||
const char * const buffer, const unsigned len)
|
||||
{
|
||||
int dlen;
|
||||
diff --git a/src/sasl.h b/src/sasl.h
|
||||
index bc7511a..98c27bf 100644
|
||||
--- a/src/sasl.h
|
||||
+++ b/src/sasl.h
|
||||
@@ -32,13 +32,13 @@ char *sasl_scram_sha1(xmpp_ctx_t *ctx, const char *challenge,
|
||||
|
||||
int base64_encoded_len(xmpp_ctx_t *ctx, const unsigned len);
|
||||
|
||||
-char *base64_encode(xmpp_ctx_t *ctx,
|
||||
+char *strophe_base64_encode(xmpp_ctx_t *ctx,
|
||||
const unsigned char * const buffer, const unsigned len);
|
||||
|
||||
int base64_decoded_len(xmpp_ctx_t *ctx,
|
||||
const char * const buffer, const unsigned len);
|
||||
|
||||
-unsigned char *base64_decode(xmpp_ctx_t *ctx,
|
||||
+unsigned char *strophe_base64_decode(xmpp_ctx_t *ctx,
|
||||
const char * const buffer, const unsigned len);
|
||||
|
||||
#endif /* _LIBXMPP_SASL_H__ */
|
||||
diff --git a/tests/test_base64.c b/tests/test_base64.c
|
||||
index 9e16862..82995b4 100644
|
||||
--- a/tests/test_base64.c
|
||||
+++ b/tests/test_base64.c
|
||||
@@ -45,31 +45,31 @@ static const char base64_5[] =
|
||||
int test_encode(xmpp_ctx_t *ctx)
|
||||
{
|
||||
char *result;
|
||||
- result = base64_encode(ctx, text_1, strlen(text_1));
|
||||
+ result = strophe_base64_encode(ctx, text_1, strlen(text_1));
|
||||
if (result == NULL) return 2;
|
||||
if (strlen(result) != strlen(base64_1)) return 1;
|
||||
if (strncmp(base64_1, result, strlen(base64_1))) return 1;
|
||||
xmpp_free(ctx,result);
|
||||
|
||||
- result = base64_encode(ctx, text_2, strlen(text_2));
|
||||
+ result = strophe_base64_encode(ctx, text_2, strlen(text_2));
|
||||
if (result == NULL) return 2;
|
||||
if (strlen(result) != strlen(base64_2)) return 1;
|
||||
if (strncmp(base64_2, result, strlen(base64_2))) return 1;
|
||||
xmpp_free(ctx,result);
|
||||
|
||||
- result = base64_encode(ctx, text_3, strlen(text_3));
|
||||
+ result = strophe_base64_encode(ctx, text_3, strlen(text_3));
|
||||
if (result == NULL) return 2;
|
||||
if (strlen(result) != strlen(base64_3)) return 1;
|
||||
if (strncmp(base64_3, result, strlen(base64_3))) return 1;
|
||||
xmpp_free(ctx,result);
|
||||
|
||||
- result = base64_encode(ctx, text_4, strlen(text_4));
|
||||
+ result = strophe_base64_encode(ctx, text_4, strlen(text_4));
|
||||
if (result == NULL) return 2;
|
||||
if (strlen(result) != strlen(base64_4)) return 1;
|
||||
if (strncmp(base64_4, result, strlen(base64_4))) return 1;
|
||||
xmpp_free(ctx,result);
|
||||
|
||||
- result = base64_encode(ctx, text_5, strlen(text_5));
|
||||
+ result = strophe_base64_encode(ctx, text_5, strlen(text_5));
|
||||
if (result == NULL) return 2;
|
||||
if (strlen(result) != strlen(base64_5)) return 1;
|
||||
if (strncmp(base64_5, result, strlen(base64_5))) return 1;
|
||||
@@ -83,31 +83,31 @@ int test_decode(xmpp_ctx_t *ctx)
|
||||
{
|
||||
unsigned char *result;
|
||||
|
||||
- result = base64_decode(ctx, base64_1, strlen(base64_1));
|
||||
+ result = strophe_base64_decode(ctx, base64_1, strlen(base64_1));
|
||||
if (result == NULL) return 2;
|
||||
if (strlen(result) != strlen(text_1)) return 1;
|
||||
if (strncmp(text_1, result, strlen(text_1))) return 1;
|
||||
xmpp_free(ctx,result);
|
||||
|
||||
- result = base64_decode(ctx, base64_2, strlen(base64_2));
|
||||
+ result = strophe_base64_decode(ctx, base64_2, strlen(base64_2));
|
||||
if (result == NULL) return 2;
|
||||
if (strlen(result) != strlen(text_2)) return 1;
|
||||
if (strncmp(text_2, result, strlen(text_2))) return 1;
|
||||
xmpp_free(ctx,result);
|
||||
|
||||
- result = base64_decode(ctx, base64_3, strlen(base64_3));
|
||||
+ result = strophe_base64_decode(ctx, base64_3, strlen(base64_3));
|
||||
if (result == NULL) return 2;
|
||||
if (strlen(result) != strlen(text_3)) return 1;
|
||||
if (strncmp(text_3, result, strlen(text_3))) return 1;
|
||||
xmpp_free(ctx,result);
|
||||
|
||||
- result = base64_decode(ctx, base64_4, strlen(base64_4));
|
||||
+ result = strophe_base64_decode(ctx, base64_4, strlen(base64_4));
|
||||
if (result == NULL) return 2;
|
||||
if (strlen(result) != strlen(text_4)) return 1;
|
||||
if (strncmp(text_4, result, strlen(text_4))) return 1;
|
||||
xmpp_free(ctx,result);
|
||||
|
||||
- result = base64_decode(ctx, base64_5, strlen(base64_5));
|
||||
+ result = strophe_base64_decode(ctx, base64_5, strlen(base64_5));
|
||||
if (result == NULL) return 2;
|
||||
if (strlen(result) != strlen(text_5)) return 1;
|
||||
if (strncmp(text_5, result, strlen(text_5))) return 1;
|
||||
@@ -130,13 +130,13 @@ int main(int argc, char *argv[])
|
||||
|
||||
printf("testing encode... ");
|
||||
ret = test_encode(ctx);
|
||||
- if (ret) printf("base64_encode failed!\n");
|
||||
+ if (ret) printf("strophe_base64_encode failed!\n");
|
||||
if (ret) return ret;
|
||||
printf("ok.\n");
|
||||
|
||||
printf("testing decode... ");
|
||||
ret = test_decode(ctx);
|
||||
- if (ret) printf("base64_decode failed!\n");
|
||||
+ if (ret) printf("strophe_base64_decode failed!\n");
|
||||
if (ret) return ret;
|
||||
printf("ok.\n");
|
||||
|
||||
Loading…
Add table
Reference in a new issue