summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnton <anton@picapica>2021-07-10 02:45:04 +0400
committerAnton <anton@picapica>2021-07-10 02:45:04 +0400
commit16508b609a8f45f16fd9161fb79b20b3e8b2056f (patch)
treee0a3f614f30d8f26d170eb20a9b65e7537f9d971
parent176381a1bdbd595db2934834f8d53a7e401dde38 (diff)
downloadpica-pica-16508b609a8f45f16fd9161fb79b20b3e8b2056f.tar.gz
pica-pica-16508b609a8f45f16fd9161fb79b20b3e8b2056f.zip
fix possible segfault in PICA_id_to_base64()
-rw-r--r--PICA_id.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/PICA_id.c b/PICA_id.c
index 51d0673..f30d03f 100644
--- a/PICA_id.c
+++ b/PICA_id.c
@@ -69,6 +69,7 @@ char *PICA_id_to_base64(const unsigned char *id, char *buf)
static char localbuf[PICA_ID_SIZE * 2];
char *sourcebuf, *outputbuf = buf;
+ char *newlinepos;
long b64len;
b64 = BIO_new(BIO_f_base64());
@@ -84,8 +85,9 @@ char *PICA_id_to_base64(const unsigned char *id, char *buf)
memcpy(outputbuf, sourcebuf, b64len);
- *strchr(outputbuf, '\n') = '\0';
outputbuf[b64len] = '\0';
+ if ((newlinepos = strchr(outputbuf, '\n')))
+ *newlinepos = '\0';
BIO_free_all(biomem);