diff options
author | Justus Winter <justus@g10code.com> | 2016-06-30 12:45:15 +0200 |
---|---|---|
committer | Justus Winter <justus@g10code.com> | 2016-06-30 15:31:37 +0200 |
commit | 5003caa8fdc80afd5748835c06621014f83e6ec4 (patch) | |
tree | 9e05716b0b8842c476c53ec78c42fd54f6ab643f /tests/gpgscm/scheme.c | |
parent | gpgscm: Free memory backing string ports. (diff) | |
download | gnupg2-5003caa8fdc80afd5748835c06621014f83e6ec4.tar.xz gnupg2-5003caa8fdc80afd5748835c06621014f83e6ec4.zip |
gpgscm: Fix reallocating string ports.
* tests/gpgscm/scheme.c (realloc_port_string): Use memcpy because
Scheme strings may contain 0s.
Signed-off-by: Justus Winter <justus@g10code.com>
Diffstat (limited to '')
-rw-r--r-- | tests/gpgscm/scheme.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/tests/gpgscm/scheme.c b/tests/gpgscm/scheme.c index 5f2f205da..0a7620521 100644 --- a/tests/gpgscm/scheme.c +++ b/tests/gpgscm/scheme.c @@ -1620,12 +1620,13 @@ static void backchar(scheme *sc, int c) { static int realloc_port_string(scheme *sc, port *p) { char *start=p->rep.string.start; + size_t old_size = p->rep.string.past_the_end - start; size_t new_size=p->rep.string.past_the_end-start+1+BLOCK_SIZE; char *str=sc->malloc(new_size); if(str) { memset(str,' ',new_size-1); str[new_size-1]='\0'; - strcpy(str,start); + memcpy(str, start, old_size); p->rep.string.start=str; p->rep.string.past_the_end=str+new_size-1; p->rep.string.curr-=start-str; |