increase buffer for base64decoding and nulltemrinate anything we get

master
Steffen Pohle 1 month ago
parent 58447b8170
commit 37eda1c4d7

@ -2,6 +2,7 @@ Version 0.4:
============= =============
2026-04-17: 2026-04-17:
- adding function to request a certain headline - adding function to request a certain headline
- base64decode increase the outputbuffer by 2 bytes for null-temrinated strings
2026-04-16: 2026-04-16:
- base64encode and base64decode implemented - base64encode and base64decode implemented

@ -463,7 +463,7 @@ int base64decode(std::string input, char **obuffer, int *olen) {
// calculate and realloc size of buffer // calculate and realloc size of buffer
if (*obuffer == NULL || (1 + ilen*3/4) < *olen) { if (*obuffer == NULL || (1 + ilen*3/4) < *olen) {
*olen = 1 + ilen*3/4; *olen = 2 + ilen*3/4; // increase buffer by two ... null terminated string?
*obuffer = (char*) realloc(*obuffer, *olen); *obuffer = (char*) realloc(*obuffer, *olen);
} }
@ -493,6 +493,7 @@ int base64decode(std::string input, char **obuffer, int *olen) {
(*obuffer)[ocnt++] = c; (*obuffer)[ocnt++] = c;
} }
*olen = ocnt; *olen = ocnt;
(*obuffer)[ocnt] = 0; // nullterminate - just to prevent unseen stuff
return 1; return 1;
}; };

Loading…
Cancel
Save