mirror of
git://git.gnupg.org/gnupg.git
synced 2025-01-17 14:07:03 +01:00
agent: Handle USAGE information in KEYINFO.
* agent/agent.h (struct card_key_info_s): Add USAGE field. * agent/call-scd.c (card_keyinfo_cb): Parse USAGE field. Allow optional SERIALNO, IDSTR, and USAGE fields. Fix releasing on possible allocation error. -- Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
This commit is contained in:
parent
5264d3f58e
commit
295a6a7591
@ -392,6 +392,7 @@ struct card_key_info_s
|
|||||||
char keygrip[41];
|
char keygrip[41];
|
||||||
char *serialno;
|
char *serialno;
|
||||||
char *idstr;
|
char *idstr;
|
||||||
|
char *usage;
|
||||||
};
|
};
|
||||||
|
|
||||||
/*-- gpg-agent.c --*/
|
/*-- gpg-agent.c --*/
|
||||||
|
@ -939,6 +939,7 @@ card_keyinfo_cb (void *opaque, const char *line)
|
|||||||
int n;
|
int n;
|
||||||
struct card_key_info_s **l_p = &parm->list;
|
struct card_key_info_s **l_p = &parm->list;
|
||||||
|
|
||||||
|
/* It's going to append the information at the end. */
|
||||||
while ((*l_p))
|
while ((*l_p))
|
||||||
l_p = &(*l_p)->next;
|
l_p = &(*l_p)->next;
|
||||||
|
|
||||||
@ -976,7 +977,7 @@ card_keyinfo_cb (void *opaque, const char *line)
|
|||||||
;
|
;
|
||||||
|
|
||||||
if (!n)
|
if (!n)
|
||||||
goto parm_error;
|
goto skip;
|
||||||
|
|
||||||
keyinfo->serialno = xtrymalloc (n+1);
|
keyinfo->serialno = xtrymalloc (n+1);
|
||||||
if (!keyinfo->serialno)
|
if (!keyinfo->serialno)
|
||||||
@ -988,18 +989,34 @@ card_keyinfo_cb (void *opaque, const char *line)
|
|||||||
line = s;
|
line = s;
|
||||||
|
|
||||||
if (!*line)
|
if (!*line)
|
||||||
goto parm_error;
|
goto skip;
|
||||||
|
|
||||||
while (spacep (line))
|
while (spacep (line))
|
||||||
line++;
|
line++;
|
||||||
|
|
||||||
if (!*line)
|
if (!*line)
|
||||||
goto parm_error;
|
goto skip;
|
||||||
|
|
||||||
keyinfo->idstr = xtrystrdup (line);
|
for (s = line; *s && !spacep (s); s++)
|
||||||
|
;
|
||||||
|
|
||||||
|
keyinfo->idstr = xtrymalloc (s - line + 1);
|
||||||
if (!keyinfo->idstr)
|
if (!keyinfo->idstr)
|
||||||
goto alloc_error;
|
goto alloc_error;
|
||||||
|
memcpy (keyinfo->idstr, line, s - line);
|
||||||
|
keyinfo->idstr[s - line] = 0;
|
||||||
|
|
||||||
|
while (spacep (s))
|
||||||
|
s++;
|
||||||
|
|
||||||
|
if (!*s)
|
||||||
|
goto skip;
|
||||||
|
|
||||||
|
keyinfo->usage = xtrystrdup (s);
|
||||||
|
if (!keyinfo->usage)
|
||||||
|
goto alloc_error;
|
||||||
|
|
||||||
|
skip:
|
||||||
*l_p = keyinfo;
|
*l_p = keyinfo;
|
||||||
}
|
}
|
||||||
else if (keywordlen == 12 && !memcmp (keyword, "PINCACHE_PUT", keywordlen))
|
else if (keywordlen == 12 && !memcmp (keyword, "PINCACHE_PUT", keywordlen))
|
||||||
@ -1008,6 +1025,8 @@ card_keyinfo_cb (void *opaque, const char *line)
|
|||||||
return err;
|
return err;
|
||||||
|
|
||||||
alloc_error:
|
alloc_error:
|
||||||
|
xfree (keyinfo->serialno);
|
||||||
|
xfree (keyinfo->idstr);
|
||||||
xfree (keyinfo);
|
xfree (keyinfo);
|
||||||
if (!parm->error)
|
if (!parm->error)
|
||||||
parm->error = gpg_error_from_syserror ();
|
parm->error = gpg_error_from_syserror ();
|
||||||
@ -1031,6 +1050,7 @@ agent_card_free_keyinfo (struct card_key_info_s *l)
|
|||||||
l_next = l->next;
|
l_next = l->next;
|
||||||
xfree (l->serialno);
|
xfree (l->serialno);
|
||||||
xfree (l->idstr);
|
xfree (l->idstr);
|
||||||
|
xfree (l->usage);
|
||||||
xfree (l);
|
xfree (l);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user