mirror of
git://git.gnupg.org/gnupg.git
synced 2025-01-03 12:11:33 +01:00
common: Make gnupg_exec_tool conform to spec.
* common/exectool.c (gnupg_exec_tool): Allocate extra byte. Allow zero length read. Append hidden byte. Release memory on error. -- Signed-off-by: Werner Koch <wk@gnupg.org>
This commit is contained in:
parent
81494fd30d
commit
d19d6e1856
@ -417,24 +417,33 @@ gnupg_exec_tool (const char *pgmname, const char *argv[],
|
|||||||
if (err)
|
if (err)
|
||||||
goto leave;
|
goto leave;
|
||||||
|
|
||||||
*result = xtrymalloc (len);
|
*result = xtrymalloc (len + 1);
|
||||||
if (*result == NULL)
|
if (!*result)
|
||||||
{
|
{
|
||||||
err = my_error_from_syserror ();
|
err = my_error_from_syserror ();
|
||||||
goto leave;
|
goto leave;
|
||||||
}
|
}
|
||||||
|
|
||||||
err = es_read (output, *result, len, &nread);
|
if (len)
|
||||||
if (! err)
|
|
||||||
{
|
{
|
||||||
assert (nread == len || !"short read on memstream");
|
err = es_read (output, *result, len, &nread);
|
||||||
if (resultlen)
|
if (err)
|
||||||
*resultlen = len;
|
goto leave;
|
||||||
|
if (nread != len)
|
||||||
|
log_fatal ("%s: short read from memstream\n", __func__);
|
||||||
}
|
}
|
||||||
|
(*result)[len] = 0;
|
||||||
|
|
||||||
|
if (resultlen)
|
||||||
|
*resultlen = len;
|
||||||
|
|
||||||
leave:
|
leave:
|
||||||
if (input)
|
es_fclose (input);
|
||||||
es_fclose (input);
|
|
||||||
es_fclose (output);
|
es_fclose (output);
|
||||||
|
if (err)
|
||||||
|
{
|
||||||
|
xfree (*result);
|
||||||
|
*result = NULL;
|
||||||
|
}
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user