aboutsummaryrefslogtreecommitdiffstats
path: root/tests/gpgscm/scheme.c
diff options
context:
space:
mode:
authorJustus Winter <[email protected]>2016-06-28 16:08:01 +0000
committerJustus Winter <[email protected]>2016-06-28 16:21:50 +0000
commit56cebdc30c10eaec179a6911e308074264d876ae (patch)
tree0149b99d3e54267bb81fb702471d03ca2278f859 /tests/gpgscm/scheme.c
parentg10: Fix memory leaks. (diff)
downloadgnupg-56cebdc30c10eaec179a6911e308074264d876ae.tar.gz
gnupg-56cebdc30c10eaec179a6911e308074264d876ae.zip
gpgscm: Fix buffer overflow.
* tests/gpgscm/scheme.c (store_string): Avoid writing past allocated buffer. Signed-off-by: Justus Winter <[email protected]>
Diffstat (limited to 'tests/gpgscm/scheme.c')
-rw-r--r--tests/gpgscm/scheme.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/tests/gpgscm/scheme.c b/tests/gpgscm/scheme.c
index 486194c19..aabf4008e 100644
--- a/tests/gpgscm/scheme.c
+++ b/tests/gpgscm/scheme.c
@@ -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;