aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Shaw <[email protected]>2006-12-04 01:20:55 +0000
committerDavid Shaw <[email protected]>2006-12-04 01:20:55 +0000
commitede66f6fb5b8bdc3a59dd445b317914878dbf4e7 (patch)
treeb1e9dab239f31217415263dfbb7723d4ea2d185a
parent* keyedit.c (menu_clean): Show "already minimized" rather than (diff)
downloadgnupg-ede66f6fb5b8bdc3a59dd445b317914878dbf4e7.tar.gz
gnupg-ede66f6fb5b8bdc3a59dd445b317914878dbf4e7.zip
* ksutil.c (classify_ks_search): Try and recognize a key ID even
without the 0x prefix. This isn't exact (it's possible that a user ID string happens to be 8 or 16 digits of hex), but it's extremely unlikely. Plus GPG itself makes the same assumption.
-rw-r--r--keyserver/ChangeLog5
-rw-r--r--keyserver/ksutil.c21
2 files changed, 22 insertions, 4 deletions
diff --git a/keyserver/ChangeLog b/keyserver/ChangeLog
index ef2004a8a..b720aeeac 100644
--- a/keyserver/ChangeLog
+++ b/keyserver/ChangeLog
@@ -1,5 +1,10 @@
2006-12-03 David Shaw <[email protected]>
+ * ksutil.c (classify_ks_search): Try and recognize a key ID even
+ without the 0x prefix. This isn't exact (it's possible that a
+ user ID string happens to be 8 or 16 digits of hex), but it's
+ extremely unlikely. Plus GPG itself makes the same assumption.
+
* gpgkeys_hkp.c (search_key): HKP keyservers like the 0x to be
present when searching by keyID.
diff --git a/keyserver/ksutil.c b/keyserver/ksutil.c
index 44224bc64..23dbc8f07 100644
--- a/keyserver/ksutil.c
+++ b/keyserver/ksutil.c
@@ -350,6 +350,10 @@ print_nocr(FILE *stream,const char *str)
}
}
+#define HEX "abcdefABCDEF1234567890"
+
+/* Return what sort of item is being searched for. *search is
+ permuted to remove any special indicators of a search type. */
enum ks_search_type
classify_ks_search(const char **search)
{
@@ -370,14 +374,12 @@ classify_ks_search(const char **search)
case '0':
if((*search)[1]=='x')
{
- if(strlen(*search)==10
- && strspn(*search,"abcdefABCDEF1234567890x")==10)
+ if(strlen(*search)==10 && strspn(*search,HEX"x")==10)
{
(*search)+=2;
return KS_SEARCH_KEYID_SHORT;
}
- else if(strlen(*search)==18
- && strspn(*search,"abcdefABCDEF1234567890x")==18)
+ else if(strlen(*search)==18 && strspn(*search,HEX"x")==18)
{
(*search)+=2;
return KS_SEARCH_KEYID_LONG;
@@ -385,6 +387,17 @@ classify_ks_search(const char **search)
}
/* fall through */
default:
+ /* Try and recognize a key ID. This isn't exact (it's possible
+ that a user ID string happens to be 8 or 16 digits of hex),
+ but it's extremely unlikely. Plus the main GPG program does
+ this also, and consistency is good. */
+
+ if(strlen(*search)==8 && strspn(*search,HEX)==8)
+ return KS_SEARCH_KEYID_SHORT;
+ else if(strlen(*search)==16 && strspn(*search,HEX)==16)
+ return KS_SEARCH_KEYID_LONG;
+
+ /* Last resort */
return KS_SEARCH_SUBSTR;
}
}