~ubuntu-branches/ubuntu/natty/gnupg/natty

« back to all changes in this revision

Viewing changes to g10/armor.c

  • Committer: Bazaar Package Importer
  • Author(s): Michael Bienia
  • Date: 2008-07-21 02:02:14 UTC
  • mfrom: (1.1.9 lenny)
  • Revision ID: james.westby@ubuntu.com-20080721020214-uh0hl0rfbog71as4
Tags: 1.4.9-3ubuntu1
* Merge from debian unstable (lp: #225005), remaining changes:
  - Add 'debian/patches/50_disable_mlock_test.dpatch': Disable mlock() test
    since it fails with ulimit 0 (on buildds).
  - Add 'debian/patches/61_use_agent_default.dpatch': Patch to set gpg
    (or gpg2) and gpgsm to use a passphrase agent by default (lp: 15485)
  - Add libcurl4-gnutls-dev to Build-Depends to fix gpg running into a
    timeout updating the keyring (lp: 62864)
* Dropped Ubuntu patches, applied upstream:
  - 50_show_primary_only.dpatch
  - 60_install_options_skel.dpatch
* Add 'debian/patches/55_curl_typefix.dpatch': Fix a build error with recent
  curl and gcc 4.3 (lp: #247679). Patch taken from upstream:
  http://lists.gnupg.org/pipermail/gnupg-devel/2008-April/024344.html

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* armor.c - Armor flter
2
 
 * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
3
 
 *               2006 Free Software Foundation, Inc.
 
2
 * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
 
3
 *               2007 Free Software Foundation, Inc.
4
4
 *
5
5
 * This file is part of GnuPG.
6
6
 *
7
7
 * GnuPG is free software; you can redistribute it and/or modify
8
8
 * it under the terms of the GNU General Public License as published by
9
 
 * the Free Software Foundation; either version 2 of the License, or
 
9
 * the Free Software Foundation; either version 3 of the License, or
10
10
 * (at your option) any later version.
11
11
 *
12
12
 * GnuPG is distributed in the hope that it will be useful,
15
15
 * GNU General Public License for more details.
16
16
 *
17
17
 * You should have received a copy of the GNU General Public License
18
 
 * along with this program; if not, write to the Free Software
19
 
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
20
 
 * USA.
 
18
 * along with this program; if not, see <http://www.gnu.org/licenses/>.
21
19
 */
22
20
 
23
21
#include <config.h>
314
312
    return found;
315
313
}
316
314
 
 
315
/* Returns true if this is a valid armor tag as per RFC-2440bis-21. */
 
316
static int
 
317
is_armor_tag(const char *line)
 
318
{
 
319
  if(strncmp(line,"Version",7)==0
 
320
     || strncmp(line,"Comment",7)==0
 
321
     || strncmp(line,"MessageID",9)==0
 
322
     || strncmp(line,"Hash",4)==0
 
323
     || strncmp(line,"Charset",7)==0)
 
324
    return 1;
317
325
 
 
326
  return 0;
 
327
}
318
328
 
319
329
/****************
320
330
 * Check whether this is a armor line.
344
354
       --rfc2440 is set since 2440 reads "The header lines, therefore,
345
355
       MUST start at the beginning of a line, and MUST NOT have text
346
356
       following them on the same line."  It is unclear whether "text"
347
 
       refers to all text or just non-whitespace text. */
 
357
       refers to all text or just non-whitespace text.  4880 clarified
 
358
       this was only non-whitespace text. */
348
359
 
349
360
    if(RFC2440)
350
361
      {
424
435
        putc('\n', stderr);
425
436
    }
426
437
 
427
 
    if( afx->in_cleartext ) {
 
438
    if( afx->in_cleartext )
 
439
      {
428
440
        if( (hashes=parse_hash_header( line )) )
429
 
            afx->hashes |= hashes;
 
441
          afx->hashes |= hashes;
430
442
        else if( strlen(line) > 15 && !memcmp( line, "NotDashEscaped:", 15 ) )
431
 
            afx->not_dash_escaped = 1;
432
 
        else {
 
443
          afx->not_dash_escaped = 1;
 
444
        else
 
445
          {
433
446
            log_error(_("invalid clearsig header\n"));
434
447
            return -1;
435
 
        }
436
 
    }
 
448
          }
 
449
      }
 
450
    else if(!is_armor_tag(line))
 
451
      {
 
452
        /* Section 6.2: "Unknown keys should be reported to the user,
 
453
           but OpenPGP should continue to process the message."  Note
 
454
           that in a clearsigned message this applies to the signature
 
455
           part (i.e. "BEGIN PGP SIGNATURE") and not the signed data
 
456
           ("BEGIN PGP SIGNED MESSAGE").  The only key allowed in the
 
457
           signed data section is "Hash". */
 
458
 
 
459
        log_info(_("unknown armor header: "));
 
460
        print_string( stderr, line, len, 0 );
 
461
        putc('\n', stderr);
 
462
      }
 
463
 
437
464
    return 1;
438
465
}
439
466