[svn] GnuPG - r4067 - in trunk: g10 include util
svn author dshaw
cvs at cvs.gnupg.org
Thu Mar 16 23:40:06 CET 2006
Author: dshaw
Date: 2006-03-16 23:40:04 +0100 (Thu, 16 Mar 2006)
New Revision: 4067
Modified:
trunk/g10/keyserver.c
trunk/include/ChangeLog
trunk/include/util.h
trunk/util/ChangeLog
trunk/util/cert.c
Log:
* cert.c (get_cert): Handle the fixed IPGP type with fingerprint.
Modified: trunk/g10/keyserver.c
===================================================================
--- trunk/g10/keyserver.c 2006-03-14 03:16:21 UTC (rev 4066)
+++ trunk/g10/keyserver.c 2006-03-16 22:40:04 UTC (rev 4067)
@@ -1993,7 +1993,7 @@
if(domain)
*domain='.';
- type=get_cert(look,max_cert_size,&key,&url);
+ type=get_cert(look,max_cert_size,&key,NULL,NULL,&url);
if(type==1)
{
int armor_status=opt.no_armor;
Modified: trunk/include/ChangeLog
===================================================================
--- trunk/include/ChangeLog 2006-03-14 03:16:21 UTC (rev 4066)
+++ trunk/include/ChangeLog 2006-03-16 22:40:04 UTC (rev 4067)
@@ -1,3 +1,7 @@
+2006-03-16 David Shaw <dshaw at jabberwocky.com>
+
+ * util.h: Handle the fixed IPGP type with fingerprint.
+
2006-02-14 Werner Koch <wk at gnupg.org>
* errors.h (G10ERR_NO_DATA): New.
Modified: trunk/include/util.h
===================================================================
--- trunk/include/util.h 2006-03-14 03:16:21 UTC (rev 4066)
+++ trunk/include/util.h 2006-03-16 22:40:04 UTC (rev 4067)
@@ -1,6 +1,6 @@
/* util.h
- * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003
- * 2004 Free Software Foundation, Inc.
+ * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
+ * 2006 Free Software Foundation, Inc.
*
* This file is part of GNUPG.
*
@@ -257,7 +257,8 @@
char *get_pka_info (const char *address, unsigned char *fpr);
/*-- cert.c --*/
-int get_cert(const char *name,size_t max_size,IOBUF *iobuf,char **url);
+int get_cert(const char *name,size_t max_size,IOBUF *iobuf,
+ unsigned char **fpr,size_t *fpr_len,char **url);
/**** other missing stuff ****/
#ifndef HAVE_ATEXIT /* For SunOS */
Modified: trunk/util/ChangeLog
===================================================================
--- trunk/util/ChangeLog 2006-03-14 03:16:21 UTC (rev 4066)
+++ trunk/util/ChangeLog 2006-03-16 22:40:04 UTC (rev 4067)
@@ -1,3 +1,7 @@
+2006-03-16 David Shaw <dshaw at jabberwocky.com>
+
+ * cert.c (get_cert): Handle the fixed IPGP type with fingerprint.
+
2006-03-08 David Shaw <dshaw at jabberwocky.com>
* argparse.c (default_strusage): Update copyright year to 2006.
Modified: trunk/util/cert.c
===================================================================
--- trunk/util/cert.c 2006-03-14 03:16:21 UTC (rev 4066)
+++ trunk/util/cert.c 2006-03-16 22:40:04 UTC (rev 4067)
@@ -1,5 +1,5 @@
/* cert.c - DNS CERT code
- * Copyright (C) 2005 Free Software Foundation, Inc.
+ * Copyright (C) 2005, 2006 Free Software Foundation, Inc.
*
* This file is part of GNUPG.
*
@@ -33,6 +33,7 @@
#include "memory.h"
#endif
#include "iobuf.h"
+#include "util.h"
/* Not every installation has gotten around to supporting CERTs
yet... */
@@ -45,12 +46,19 @@
/* Returns -1 on error, 0 for no answer, 1 for PGP provided and 2 for
IPGP provided. */
int
-get_cert(const char *name,size_t max_size,IOBUF *iobuf,char **url)
+get_cert(const char *name,size_t max_size,IOBUF *iobuf,
+ unsigned char **fpr,size_t *fpr_len,char **url)
{
unsigned char *answer;
int r,ret=-1;
u16 count;
+ if(fpr)
+ *fpr=NULL;
+
+ if(url)
+ *url=NULL;
+
answer=xmalloc(max_size);
r=res_query(name,C_IN,T_CERT,answer,max_size);
@@ -90,7 +98,8 @@
pt+=rc;
- /* Truncated message? */
+ /* Truncated message? 15 bytes takes us to the point where
+ we start looking at the ctype. */
if((emsg-pt)<15)
break;
@@ -127,26 +136,41 @@
dlen-=5;
- if(ctype==3 && iobuf)
+ /* 15 bytes takes us to here */
+
+ if(ctype==3 && iobuf && dlen)
{
/* PGP type */
*iobuf=iobuf_temp_with_content((char *)pt,dlen);
ret=1;
break;
}
-#if 0
- else if(ctype==6 && dlen<1023 && url)
+ else if(ctype==6 && dlen && dlen<1023 && dlen>=pt[0]+1
+ && fpr && fpr_len && url)
{
- /* Sanity check the IPGP URL type that the URL isn't too
- long */
+ /* IPGP type */
+ *fpr_len=pt[0];
- *url=xmalloc(dlen+1);
- memcpy(*url,pt,dlen);
- (*url)[dlen]='\0';
+ if(*fpr_len)
+ {
+ *fpr=xmalloc(*fpr_len);
+ memcpy(*fpr,&pt[1],*fpr_len);
+ }
+ else
+ *fpr=NULL;
+
+ if(dlen>*fpr_len+1)
+ {
+ *url=xmalloc(dlen-(*fpr_len+1)+1);
+ memcpy(*url,&pt[*fpr_len+1],dlen-(*fpr_len+1));
+ (*url)[dlen-(*fpr_len+1)]='\0';
+ }
+ else
+ *url=NULL;
+
ret=2;
break;
}
-#endif
/* Neither type matches, so go around to the next answer. */
pt+=dlen;
@@ -162,7 +186,8 @@
#else /* !USE_DNS_CERT */
int
-get_cert(const char *name,size_t max_size,IOBUF *iobuf,char **url)
+get_cert(const char *name,size_t max_size,IOBUF *iobuf,
+ unsigned char **fpr,size_t *fpr_len,char **url)
{
return -1;
}
@@ -175,6 +200,8 @@
int
main(int argc,char *argv[])
{
+ unsigned char *fpr;
+ size_t fpr_len;
char *url;
int rc;
IOBUF iobuf;
@@ -187,7 +214,7 @@
printf("CERT lookup on %s\n",argv[1]);
- rc=get_cert(argv[1],16384,&iobuf,&url);
+ rc=get_cert(argv[1],16384,&iobuf,&fpr,&fpr_len,&url);
if(rc==-1)
printf("error\n");
else if(rc==0)
@@ -199,7 +226,23 @@
}
else if(rc==2)
{
- printf("URL found: %s\n",url);
+ if(fpr)
+ {
+ size_t i;
+ printf("Fingerprint found (%d bytes): ",fpr_len);
+ for(i=0;i<fpr_len;i++)
+ printf("%02X",fpr[i]);
+ printf("\n");
+ }
+ else
+ printf("No fingerprint found\n");
+
+ if(url)
+ printf("URL found: %s\n",url);
+ else
+ printf("No URL found\n");
+
+ xfree(fpr);
xfree(url);
}
More information about the Gnupg-commits
mailing list