summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--common/userids.c3
-rw-r--r--g10/keydb.c12
-rw-r--r--kbx/keybox-search-desc.h3
-rw-r--r--kbx/keybox-search.c6
-rw-r--r--sm/keydb.c12
5 files changed, 15 insertions, 21 deletions
diff --git a/common/userids.c b/common/userids.c
index 5e2704362..0f03896ee 100644
--- a/common/userids.c
+++ b/common/userids.c
@@ -192,7 +192,8 @@ classify_user_id (const char *name, KEYDB_SEARCH_DESC *desc, int openpgp_hack)
}
}
desc->sn = (const unsigned char*)s;
- desc->snlen = -1;
+ desc->snlen = si - s;
+ desc->snhex = 1;
if (!*si)
mode = KEYDB_SEARCH_MODE_SN;
else
diff --git a/g10/keydb.c b/g10/keydb.c
index ef56885bd..66e7d9520 100644
--- a/g10/keydb.c
+++ b/g10/keydb.c
@@ -487,15 +487,11 @@ keydb_search_desc_dump (struct keydb_search_desc *desc)
case KEYDB_SEARCH_MODE_ISSUER:
return xasprintf ("ISSUER: '%s'", desc->u.name);
case KEYDB_SEARCH_MODE_ISSUER_SN:
- return xasprintf ("ISSUER_SN: '%*s'",
- (int) (desc->snlen == -1
- ? strlen (desc->sn) : desc->snlen),
- desc->sn);
+ return xasprintf ("ISSUER_SN: '#%.*s/%s'",
+ (int)desc->snlen,desc->sn, desc->u.name);
case KEYDB_SEARCH_MODE_SN:
- return xasprintf ("SN: '%*s'",
- (int) (desc->snlen == -1
- ? strlen (desc->sn) : desc->snlen),
- desc->sn);
+ return xasprintf ("SN: '%.*s'",
+ (int)desc->snlen, desc->sn);
case KEYDB_SEARCH_MODE_SUBJECT:
return xasprintf ("SUBJECT: '%s'", desc->u.name);
case KEYDB_SEARCH_MODE_KEYGRIP:
diff --git a/kbx/keybox-search-desc.h b/kbx/keybox-search-desc.h
index 1167b1a6d..9a0df2846 100644
--- a/kbx/keybox-search-desc.h
+++ b/kbx/keybox-search-desc.h
@@ -75,7 +75,7 @@ struct keydb_search_desc
int (*skipfnc)(void *, u32 *, int);
void *skipfncvalue;
const unsigned char *sn;
- int snlen; /* -1 := sn is a hex string */
+ unsigned short snlen;
union {
const char *name;
unsigned char fpr[32];
@@ -83,6 +83,7 @@ struct keydb_search_desc
unsigned char grip[KEYGRIP_LEN];
unsigned char ubid[UBID_LEN];
} u;
+ byte snhex; /* SN above is a hexstring and not binary. */
byte fprlen; /* Only used with KEYDB_SEARCH_MODE_FPR. */
int exact; /* Use exactly this key ('!' suffix in gpg). */
};
diff --git a/kbx/keybox-search.c b/kbx/keybox-search.c
index 67862a376..c07cd48c9 100644
--- a/kbx/keybox-search.c
+++ b/kbx/keybox-search.c
@@ -982,7 +982,7 @@ keybox_search (KEYBOX_HANDLE hd, KEYBOX_SEARCH_DESC *desc, size_t ndesc,
}
if (desc[n].skipfnc)
any_skip = 1;
- if (desc[n].snlen == -1 && !sn_array)
+ if (desc[n].snhex && !sn_array)
{
sn_array = xtrycalloc (ndesc, sizeof *sn_array);
if (!sn_array)
@@ -1042,12 +1042,12 @@ keybox_search (KEYBOX_HANDLE hd, KEYBOX_SEARCH_DESC *desc, size_t ndesc,
{
if (!desc[n].sn)
;
- else if (desc[n].snlen == -1)
+ else if (desc[n].snhex)
{
unsigned char *sn;
s = desc[n].sn;
- for (i=0; *s && *s != '/'; s++, i++)
+ for (i=0; *s && *s != '/' && i < desc[n].snlen; s++, i++)
;
odd = (i & 1);
snlen = (i+1)/2;
diff --git a/sm/keydb.c b/sm/keydb.c
index 70175a0dc..ca32162d1 100644
--- a/sm/keydb.c
+++ b/sm/keydb.c
@@ -1385,15 +1385,11 @@ keydb_search_desc_dump (struct keydb_search_desc *desc)
case KEYDB_SEARCH_MODE_ISSUER:
return xasprintf ("ISSUER: '%s'", desc->u.name);
case KEYDB_SEARCH_MODE_ISSUER_SN:
- return xasprintf ("ISSUER_SN: '%*s'",
- (int) (desc->snlen == -1
- ? strlen (desc->sn) : desc->snlen),
- desc->sn);
+ return xasprintf ("ISSUER_SN: '#%.*s/%s'",
+ (int)desc->snlen,desc->sn, desc->u.name);
case KEYDB_SEARCH_MODE_SN:
- return xasprintf ("SN: '%*s'",
- (int) (desc->snlen == -1
- ? strlen (desc->sn) : desc->snlen),
- desc->sn);
+ return xasprintf ("SN: '%.*s'",
+ (int)desc->snlen, desc->sn);
case KEYDB_SEARCH_MODE_SUBJECT:
return xasprintf ("SUBJECT: '%s'", desc->u.name);
case KEYDB_SEARCH_MODE_KEYGRIP: