~ubuntu-branches/ubuntu/precise/gnupg2/precise-proposed

« back to all changes in this revision

Viewing changes to g10/keyserver.c

  • Committer: Bazaar Package Importer
  • Author(s): Eric Dorland
  • Date: 2009-03-08 22:46:47 UTC
  • mfrom: (1.1.11 upstream)
  • Revision ID: james.westby@ubuntu.com-20090308224647-gq17gatcl71lrc2k
Tags: 2.0.11-1
* New upstream release. (Closes: #496663)
* debian/control: Make the description a little more distinctive than
  gnupg v1's. Thanks Jari Aalto. (Closes: #496323)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* keyserver.c - generic keyserver code
2
2
 * Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006,
3
 
 *               2007 Free Software Foundation, Inc.
 
3
 *               2007, 2008 Free Software Foundation, Inc.
4
4
 *
5
5
 * This file is part of GnuPG.
6
6
 *
330
330
      keyserver->scheme=xstrdup("hkp");
331
331
    }
332
332
 
333
 
  if(assume_hkp || (uri[0]=='/' && uri[1]=='/'))
 
333
  if (uri[0]=='/' && uri[1]=='/' && uri[2] == '/')
 
334
    {
 
335
      /* Three slashes means network path with a default host name.
 
336
         This is a hack because it does not crok all possible
 
337
         combiantions.  We should better repalce all code bythe parser
 
338
         from http.c.  */
 
339
      keyserver->path = xstrdup (uri+2);
 
340
    }
 
341
  else if(assume_hkp || (uri[0]=='/' && uri[1]=='/'))
334
342
    {
335
343
      /* Two slashes means network path. */
336
344
 
723
731
{
724
732
  char *answer;
725
733
 
 
734
  fflush (stdout);
 
735
 
726
736
  if(count && opt.command_fd==-1)
727
737
    {
728
738
      static int from=1;
2000
2010
    *domain='.';
2001
2011
 
2002
2012
  type=get_dns_cert(look,max_cert_size,&key,fpr,fpr_len,&url);
2003
 
  if(type==1)
 
2013
  if (!type || type == -1)
 
2014
    {
 
2015
      /* There might be an error in res_query which leads to an error
 
2016
         return (-1) in the case that nothing was found.  Thus we take
 
2017
         all errors as key not found.  */
 
2018
      rc = G10ERR_NO_PUBKEY;
 
2019
    }
 
2020
  else if (type==1)
2004
2021
    {
2005
2022
      int armor_status=opt.no_armor;
2006
2023
 
2026
2043
          spec=parse_keyserver_uri(url,1,NULL,0);
2027
2044
          if(spec)
2028
2045
            {
2029
 
              strlist_t list=NULL;
2030
 
 
2031
 
              add_to_strlist(&list,url);
2032
 
 
2033
 
              rc=keyserver_fetch(list);
2034
 
 
2035
 
              free_strlist(list);
 
2046
              rc=keyserver_import_fprint(*fpr,*fpr_len,spec);
2036
2047
              free_keyserver_spec(spec);
2037
2048
            }
2038
2049
        }
2064
2075
keyserver_import_pka(const char *name,unsigned char **fpr,size_t *fpr_len)
2065
2076
{
2066
2077
  char *uri;
2067
 
  int rc=-1;
 
2078
  int rc = G10ERR_NO_PUBKEY;
2068
2079
 
2069
 
  *fpr=xmalloc(20);
2070
 
  *fpr_len=20;
 
2080
  *fpr = xmalloc (20);
 
2081
  *fpr_len = 20;
2071
2082
 
2072
2083
  uri = get_pka_info (name, *fpr);
2073
 
  if (uri)
 
2084
  if (uri && *uri)
2074
2085
    {
 
2086
      /* An URI is available.  Lookup the key. */
2075
2087
      struct keyserver_spec *spec;
2076
2088
      spec = parse_keyserver_uri (uri, 1, NULL, 0);
2077
2089
      if (spec)
2078
2090
        {
2079
 
          rc=keyserver_import_fprint (*fpr, 20, spec);
 
2091
          rc = keyserver_import_fprint (*fpr, 20, spec);
2080
2092
          free_keyserver_spec (spec);
2081
2093
        }
2082
2094
      xfree (uri);
2083
2095
    }
2084
2096
 
2085
 
  if(rc!=0)
2086
 
    xfree(*fpr);
 
2097
  if (rc)
 
2098
    {
 
2099
      xfree(*fpr);
 
2100
      *fpr = NULL;
 
2101
    }
2087
2102
 
2088
2103
  return rc;
2089
2104
}