~ubuntu-branches/ubuntu/raring/gnupg2/raring-proposed

« back to all changes in this revision

Viewing changes to g10/misc.c

  • Committer: Bazaar Package Importer
  • Author(s): Eric Dorland
  • Date: 2009-08-23 20:48:11 UTC
  • mfrom: (1.1.12 upstream)
  • Revision ID: james.westby@ubuntu.com-20090823204811-cajik24rci4xszia
Tags: 2.0.12-1
* New upstream release. (Closes: #499569, #463270, #446494, #314068, 
  #519375, #514587)
* debian/control: Change build dependency on gs to ghoscript, since
  ghoscript has been replaced.
* debian/compat: Use debhelper v7.
* debian/control: Update Standards-Version to 3.8.2.
* debian/control: Use ${misc:Depends}.
* configure.ac: Override pkgdatadir so that it points to
  /usr/share/gnupg2. (Closes: #528734)
* debian/rules: No longer need to specify pkgdatadir at make install
  time.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* misc.c - miscellaneous functions
2
2
 * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
3
 
 *               2008 Free Software Foundation, Inc.
 
3
 *               2008, 2009 Free Software Foundation, Inc.
4
4
 *
5
5
 * This file is part of GnuPG.
6
6
 *
340
340
/* Map OpenPGP algo numbers to those used by Libgcrypt.  We need to do
341
341
   this for algorithms we implemented in Libgcrypt after they become
342
342
   part of OpenPGP.  */
343
 
static int
 
343
int
344
344
map_cipher_openpgp_to_gcry (int algo)
345
345
{
346
346
  switch (algo)
400
400
  if ( algo < 0 || algo > 110 || algo == 5 || algo == 6 )
401
401
    return gpg_error (GPG_ERR_CIPHER_ALGO);
402
402
 
403
 
  /* Camellia is not yet defined for OpenPGP thus only allow it if
404
 
     requested.  */
405
 
#ifndef USE_CAMELLIA
406
 
  if (algo == CIPHER_ALGO_CAMELLIA128 
407
 
      || algo == CIPHER_ALGO_CAMELLIA192
408
 
      || algo == CIPHER_ALGO_CAMELLIA256)
409
 
    return gpg_error (GPG_ERR_CIPHER_ALGO);
410
 
#endif
411
 
 
412
403
  return gcry_cipher_test_algo (map_cipher_openpgp_to_gcry (algo));
413
404
}
414
405
 
1215
1206
}
1216
1207
 
1217
1208
 
1218
 
/* Return a new malloced string by unescaping the string S.  Escaping
1219
 
   is percent escaping and '+'/space mapping.  A binary nul will
1220
 
   silently be replaced by a 0xFF. */
1221
 
char *
1222
 
unescape_percent_string (const unsigned char *s)
1223
 
{
1224
 
  char *buffer, *d;
1225
 
 
1226
 
  buffer = d = xmalloc (strlen (s)+1);
1227
 
  while (*s)
1228
 
    {
1229
 
      if (*s == '%' && s[1] && s[2])
1230
 
        { 
1231
 
          s++;
1232
 
          *d = xtoi_2 (s);
1233
 
          if (!*d)
1234
 
            *d = '\xff';
1235
 
          d++;
1236
 
          s += 2;
1237
 
        }
1238
 
      else if (*s == '+')
1239
 
        {
1240
 
          *d++ = ' ';
1241
 
          s++;
1242
 
        }
1243
 
      else
1244
 
        *d++ = *s++;
1245
 
    }
1246
 
  *d = 0; 
1247
 
  return buffer;
1248
 
}
1249
 
 
1250
 
 
1251
1209
/* Check whether the string has characters not valid in an RFC-822
1252
1210
   address.  To cope with OpenPGP we ignore allow non-ascii characters
1253
1211
   so that for example umlauts are legal in an email address.  An