gpgscm: Fix buffer overflow.

* tests/gpgscm/scheme.c (store_string): Avoid writing past allocated
buffer.

Signed-off-by: Justus Winter <justus@g10code.com>
This commit is contained in:
Justus Winter 2016-06-28 18:08:01 +02:00
parent c57501cc5f
commit 56cebdc30c
1 changed files with 2 additions and 1 deletions

View File

@ -1026,7 +1026,8 @@ static char *store_string(scheme *sc, int len_str, const char *str, char fill) {
return sc->strbuff;
}
if(str!=0) {
snprintf(q, len_str+1, "%s", str);
memcpy (q, str, len_str);
q[len_str]=0;
} else {
memset(q, fill, len_str);
q[len_str]=0;