[svn] GnuPG - r4363 - branches/STABLE-BRANCH-1-4/keyserver
svn author dshaw
cvs at cvs.gnupg.org
Mon Dec 4 02:20:55 CET 2006
Author: dshaw
Date: 2006-12-04 02:20:55 +0100 (Mon, 04 Dec 2006)
New Revision: 4363
Modified:
branches/STABLE-BRANCH-1-4/keyserver/ChangeLog
branches/STABLE-BRANCH-1-4/keyserver/ksutil.c
Log:
* 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.
Modified: branches/STABLE-BRANCH-1-4/keyserver/ChangeLog
===================================================================
--- branches/STABLE-BRANCH-1-4/keyserver/ChangeLog 2006-12-03 06:27:49 UTC (rev 4362)
+++ branches/STABLE-BRANCH-1-4/keyserver/ChangeLog 2006-12-04 01:20:55 UTC (rev 4363)
@@ -1,5 +1,10 @@
2006-12-03 David Shaw <dshaw at jabberwocky.com>
+ * 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.
Modified: branches/STABLE-BRANCH-1-4/keyserver/ksutil.c
===================================================================
--- branches/STABLE-BRANCH-1-4/keyserver/ksutil.c 2006-12-03 06:27:49 UTC (rev 4362)
+++ branches/STABLE-BRANCH-1-4/keyserver/ksutil.c 2006-12-04 01:20:55 UTC (rev 4363)
@@ -350,6 +350,10 @@
}
}
+#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 @@
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 @@
}
/* 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;
}
}
More information about the Gnupg-commits
mailing list