Robustness fix.

Add group to the --gpgconf-list.
This commit is contained in:
Werner Koch 2008-06-19 10:45:16 +00:00
parent df066f970f
commit e573011dda
4 changed files with 28 additions and 10 deletions

View File

@ -1,3 +1,10 @@
2008-06-19 Werner Koch <wk@g10code.com>
* sysutils.c: Remove <ctype.h>.
(fd_translate_max): Use macro for the size.
(translate_table_init): Protect read against EINTR and replace
isspace by spacep.
2008-06-18 Marcus Brinkmann <marcus@g10code.de>
* sysutils.c (TRANS_MAX): Bump up to 350 to be on the safe side.

View File

@ -50,7 +50,6 @@
# include <pth.h>
#endif
#include <fcntl.h>
#include <ctype.h>
#include "util.h"
#include "i18n.h"
@ -301,7 +300,7 @@ static struct
{
int from;
int to;
} fd_translate[8];
} fd_translate[FD_TRANSLATE_MAX];
/* Number of entries used in fd_translate. */
static int fd_translate_len;
@ -310,7 +309,9 @@ static int fd_translate_len;
/* Initialize the fd translation table. This reads one line from
stdin which is expected to be in the format "FROM TO [...]" where
each "FROM TO" pair are two handle numbers. Handle number FROM on
the command line is translated to handle number TO. */
the command line is translated to handle number TO.
Note that this function may be called while still being setuid. */
void
translate_table_init (void)
{
@ -327,7 +328,9 @@ translate_table_init (void)
/* We always read one line from stdin. */
for (idx = 0; idx < TRANS_MAX; idx++)
{
res = read (0, &line[idx], 1);
do
res = read (0, &line[idx], 1);
while (res == -1 && errno == EINTR);
if (res != 1)
break;
if (line[idx] == '\n')
@ -340,7 +343,11 @@ translate_table_init (void)
{
char buf[1];
do
res = read (0, buf, 1);
{
do
res = read (0, buf, 1);
while (res == -1 && errno == EINTR);
}
while (res == 1 && *buf != '\n');
}
@ -354,21 +361,21 @@ translate_table_init (void)
unsigned long to;
char *tail;
while (isspace (*linep))
while (spacep (linep))
linep++;
if (*linep == '\0')
break;
from = strtoul (linep, &tail, 0);
if (tail == NULL || ! (*tail == '\0' || isspace (*tail)))
if (tail == NULL || ! (*tail == '\0' || spacep (tail)))
break;
linep = tail;
while (isspace (*linep))
while (spacep (linep))
linep++;
if (*linep == '\0')
break;
to = strtoul (linep, &tail, 0);
if (tail == NULL || ! (*tail == '\0' || isspace (*tail)))
if (tail == NULL || ! (*tail == '\0' || spacep (tail)))
break;
linep = tail;

View File

@ -1,3 +1,7 @@
2008-06-19 Werner Koch <wk@g10code.com>
* gpg.c (gpgconf_list): Add "group".
2008-06-18 Marcus Brinkmann <marcus@g10code.de>
* gpg.c (enum cmd_and_opt_values): New option

View File

@ -1562,7 +1562,7 @@ gpgconf_list (const char *configfile)
printf ("allow-pka-lookup:%lu:\n", GC_OPT_FLAG_NONE);
printf ("log-file:%lu:\n", GC_OPT_FLAG_NONE);
printf ("debug-level:%lu:\"none:\n", GC_OPT_FLAG_DEFAULT);
printf ("group:%lu:\n", GC_OPT_FLAG_NONE);
xfree (configfile_esc);
}