diff options
| author | Anton <anton@picapica> | 2021-07-10 02:45:04 +0400 |
|---|---|---|
| committer | Anton <anton@picapica> | 2021-07-10 02:45:04 +0400 |
| commit | 16508b609a8f45f16fd9161fb79b20b3e8b2056f (patch) | |
| tree | e0a3f614f30d8f26d170eb20a9b65e7537f9d971 | |
| parent | 176381a1bdbd595db2934834f8d53a7e401dde38 (diff) | |
| download | pica-pica-16508b609a8f45f16fd9161fb79b20b3e8b2056f.tar.gz pica-pica-16508b609a8f45f16fd9161fb79b20b3e8b2056f.zip | |
fix possible segfault in PICA_id_to_base64()
| -rw-r--r-- | PICA_id.c | 4 |
1 files changed, 3 insertions, 1 deletions
@@ -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); |
