~ubuntu-branches/ubuntu/maverick/exim4/maverick-updates

« back to all changes in this revision

Viewing changes to src/crypt16.c

  • Committer: Bazaar Package Importer
  • Author(s): Michael Bienia
  • Date: 2010-01-01 16:28:19 UTC
  • mfrom: (2.1.5 sid)
  • Revision ID: james.westby@ubuntu.com-20100101162819-htn71my7yj4v1vkr
Tags: 4.71-3ubuntu1
* Merge with Debian unstable (lp: #501657). Remaining changes:
  + debian/patches/71_exiq_grep_error_on_messages_without_size.dpatch:
    Improve handling of broken messages when "exim4 -bp" (mailq) reports
    lines without size info.
  + Don't declare a Provides: default-mta; in Ubuntu, we want postfix to be
    the default.
  + debian/control: Change build dependencies to MySQL 5.1.
  + debian/{control,rules}: add and enable hardened build for PIE
    (Debian bug 542726).

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* $Cambridge: exim/exim-src/src/crypt16.c,v 1.1 2004/10/07 10:39:01 ph10 Exp $ */
 
2
 
 
3
/*
 
4
 * Copyright (c) 2000-2002
 
5
 *   Chris Adams <cmadams@iruntheinter.net>
 
6
 *   written for HiWAAY Internet Services
 
7
 *
 
8
 * This program is free software; you can redistribute it and/or modify
 
9
 * it under the terms of the GNU General Public License as published by
 
10
 * the Free Software Foundation; either version 2 of the License, or
 
11
 * (at your option) any later version.
 
12
 *
 
13
 * This program is distributed in the hope that it will be useful,
 
14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
16
 * GNU General Public License for more details.
 
17
 *
 
18
 * You should have received a copy of the GNU General Public License
 
19
 * along with this program; if not, write to the Free Software
 
20
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
 
21
 * USA
 
22
 */
 
23
 
 
24
/*
 
25
 * Adapted for Exim by Tamas TEVESZ <ice@extreme.hu>
 
26
 * Further adapted by Philip Hazel to cut out this function for operating
 
27
 *   systems that have a built-in version.
 
28
 */
 
29
 
 
30
/* The OS has a built-in crypt16(). Some compilers don't like compiling empty
 
31
modules, so keep them happy with a dummy when skipping the rest. */
 
32
 
 
33
#include "config.h"
 
34
 
 
35
#ifdef HAVE_CRYPT16
 
36
static void dummy(int x) { dummy(x-1); }
 
37
#else
 
38
 
 
39
/* The OS doesn't have a built-in crypt16(). Compile this one. */
 
40
 
 
41
#include <unistd.h>
 
42
#include <string.h>
 
43
#include "os.h"
 
44
 
 
45
#ifdef CRYPT_H
 
46
#include <crypt.h>
 
47
#endif
 
48
 
 
49
char *crypt16(char *key, char *salt)
 
50
{
 
51
       static char res[25];
 
52
       static char s2[3];
 
53
       char *p;
 
54
 
 
55
       /* Clear the string of any previous data */
 
56
       memset (res, 0, sizeof (res));
 
57
 
 
58
       /* crypt the first part */
 
59
       p = crypt (key, salt);
 
60
       strncpy (res, p, 13);
 
61
 
 
62
       if (strlen (key) > 8)
 
63
       {
 
64
               /* crypt the rest
 
65
                * the first two characters of the first block (not counting
 
66
                * the salt) make up the new salt */
 
67
               strncpy (s2, &(res[2]), 2);
 
68
               p = crypt (&(key[8]), s2);
 
69
               strncpy (&(res[13]), &(p[2]), 11);
 
70
               memset (s2, 0, sizeof (s2));
 
71
       }
 
72
 
 
73
       return (res);
 
74
}
 
75
#endif
 
76
 
 
77
/* End of crypt16.c */