Module: kamailio Branch: 6.0 Commit: 6e51390db6b60178b58c2a9f619011aae4f35eea URL: https://github.com/kamailio/kamailio/commit/6e51390db6b60178b58c2a9f619011aae4f35eea
Author: Daniel-Constantin Mierla <[email protected]> Committer: Daniel-Constantin Mierla <[email protected]> Date: 2026-01-08T21:33:47+01:00 core: split input/output parameters validation for base64url_enc()/_dec() - update after commit d7210bc1102ae820f9e6f8998694271ac2a320fe, allowing again null input with lenght 0 that is used by some modules (e.g., topos_htable) - GH #4546 (cherry picked from commit 21f84cd08052a656ffc74480ee22b2ab6b7a02f0) --- Modified: src/core/basex.c --- Diff: https://github.com/kamailio/kamailio/commit/6e51390db6b60178b58c2a9f619011aae4f35eea.diff Patch: https://github.com/kamailio/kamailio/commit/6e51390db6b60178b58c2a9f619011aae4f35eea.patch --- diff --git a/src/core/basex.c b/src/core/basex.c index 554600564f4..d30353f5e39 100644 --- a/src/core/basex.c +++ b/src/core/basex.c @@ -497,27 +497,26 @@ int base64url_enc(char *in, int ilen, char *out, int osize) unsigned int block; int olen; - - /* Add input validation */ - if(!in || !out) { - LM_ERR("null pointer parameter\n"); + if(!out) { + LM_ERR("null output pointer parameter\n"); return -1; } - if(ilen < 0) { LM_ERR("invalid input length %d\n", ilen); return -1; } - if(osize < 1) { LM_ERR("invalid output size %d\n", osize); return -1; } - if(ilen == 0) { out[0] = '\0'; return 0; } + if(!in) { + LM_ERR("null input pointer parameter\n"); + return -1; + } /* Protect against integer overflow Max safe ilen: (INT_MAX >> 2) to avoid overflow @@ -563,12 +562,10 @@ int base64url_dec(char *in, int ilen, char *out, int osize) char c; int olen; - /* Early error and input validation */ - if(!in || !out) { - LM_ERR("invalid input parameters\n"); + if(!out) { + LM_ERR("null output pointer parameter\n"); return -1; } - if(ilen < 0) { LM_ERR("invalid input length %d\n", ilen); return -1; @@ -577,11 +574,14 @@ int base64url_dec(char *in, int ilen, char *out, int osize) LM_ERR("invalid output size %d\n", osize); return -1; } - if(ilen == 0) { out[0] = '\0'; return 0; } + if(!in) { + LM_ERR("null input pointer parameter\n"); + return -1; + } for(n = 0, i = ilen - 1; i >= 0 && in[i] == '='; i--) n++; _______________________________________________ Kamailio - Development Mailing List -- [email protected] To unsubscribe send an email to [email protected] Important: keep the mailing list in the recipients, do not reply only to the sender!
