~ubuntu-branches/ubuntu/hardy/openswan/hardy-updates

« back to all changes in this revision

Viewing changes to debian/openswan-modules-source-build/modules/openswan/linux/lib/libfreeswan/addrtoa.c

  • Committer: Bazaar Package Importer
  • Author(s): Rene Mayrhofer
  • Date: 2005-01-27 16:10:11 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20050127161011-idgybmyz3vwhpfiq
Tags: 2.3.0-2
Urgency HIGH due to security issue and problems with build-deps in sarge.
* Fix the security issue. Please see
  http://www.idefense.com/application/poi/display?id=190&
      type=vulnerabilities&flashstatus=false
  for more details. Thanks to Martin Schulze for informing me about
  this issue.
  Closes: #292458: Openswan XAUTH/PAM Buffer Overflow Vulnerability
* Added a Build-Dependency to lynx.
  Closes: #291143: openswan: FTBFS: Missing build dependency.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * addresses to ASCII
3
 
 * Copyright (C) 1998, 1999  Henry Spencer.
4
 
 * 
5
 
 * This library is free software; you can redistribute it and/or modify it
6
 
 * under the terms of the GNU Library General Public License as published by
7
 
 * the Free Software Foundation; either version 2 of the License, or (at your
8
 
 * option) any later version.  See <http://www.fsf.org/copyleft/lgpl.txt>.
9
 
 * 
10
 
 * This library is distributed in the hope that it will be useful, but
11
 
 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12
 
 * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
13
 
 * License for more details.
14
 
 *
15
 
 * RCSID $Id: addrtoa.c,v 1.7.36.1 2004/03/21 05:23:31 mcr Exp $
16
 
 */
17
 
#include "internal.h"
18
 
#include "openswan.h"
19
 
 
20
 
#define NBYTES  4               /* bytes in an address */
21
 
#define PERBYTE 4               /* three digits plus a dot or NUL */
22
 
#define BUFLEN  (NBYTES*PERBYTE)
23
 
 
24
 
#if BUFLEN != ADDRTOA_BUF
25
 
#error  "ADDRTOA_BUF in openswan.h inconsistent with addrtoa() code"
26
 
#endif
27
 
 
28
 
/*
29
 
 - addrtoa - convert binary address to ASCII dotted decimal
30
 
 */
31
 
size_t                          /* space needed for full conversion */
32
 
addrtoa(addr, format, dst, dstlen)
33
 
struct in_addr addr;
34
 
int format;                     /* character */
35
 
char *dst;                      /* need not be valid if dstlen is 0 */
36
 
size_t dstlen;
37
 
{
38
 
        unsigned long a = ntohl(addr.s_addr);
39
 
        int i;
40
 
        size_t n;
41
 
        unsigned long byte;
42
 
        char buf[BUFLEN];
43
 
        char *p;
44
 
 
45
 
        switch (format) {
46
 
        case 0:
47
 
                break;
48
 
        default:
49
 
                return 0;
50
 
                break;
51
 
        }
52
 
 
53
 
        p = buf;
54
 
        for (i = NBYTES-1; i >= 0; i--) {
55
 
                byte = (a >> (i*8)) & 0xff;
56
 
                p += ultoa(byte, 10, p, PERBYTE);
57
 
                if (i != 0)
58
 
                        *(p-1) = '.';
59
 
        }
60
 
        n = p - buf;
61
 
 
62
 
        if (dstlen > 0) {
63
 
                if (n > dstlen)
64
 
                        buf[dstlen - 1] = '\0';
65
 
                strcpy(dst, buf);
66
 
        }
67
 
        return n;
68
 
}