1
0
mirror of git://git.gnupg.org/gnupg.git synced 2024-12-22 10:19:57 +01:00

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>
This commit is contained in:
Justus Winter 2016-06-30 12:45:15 +02:00
parent 599ad21104
commit 5003caa8fd

View File

@ -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;