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

« back to all changes in this revision

Viewing changes to lib/libopenswan/portof.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
 * low-level ip_address ugliness
 
3
 * Copyright (C) 2000  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: portof.c,v 1.6 2004/04/09 18:00:36 mcr Exp $
 
16
 */
 
17
#include "internal.h"
 
18
#include "openswan.h"
 
19
 
 
20
/*
 
21
 - portof - get the port field of an ip_address
 
22
 */
 
23
int                             /* network order */
 
24
portof(src)
 
25
const ip_address *src;
 
26
{
 
27
        switch (src->u.v4.sin_family) {
 
28
        case AF_INET:
 
29
                return src->u.v4.sin_port;
 
30
                break;
 
31
        case AF_INET6:
 
32
                return src->u.v6.sin6_port;
 
33
                break;
 
34
        default:
 
35
                return -1;      /* "can't happen" */
 
36
                break;
 
37
        }
 
38
}
 
39
 
 
40
/*
 
41
 - setportof - set the port field of an ip_address
 
42
 */
 
43
void
 
44
setportof(port, dst)
 
45
int port;                       /* network order */
 
46
ip_address *dst;
 
47
{
 
48
        switch (dst->u.v4.sin_family) {
 
49
        case AF_INET:
 
50
                dst->u.v4.sin_port = port;
 
51
                break;
 
52
        case AF_INET6:
 
53
                dst->u.v6.sin6_port = port;
 
54
                break;
 
55
        }
 
56
}
 
57
 
 
58
/*
 
59
 - sockaddrof - get a pointer to the sockaddr hiding inside an ip_address
 
60
 */
 
61
struct sockaddr *
 
62
sockaddrof(src)
 
63
ip_address *src;
 
64
{
 
65
        switch (src->u.v4.sin_family) {
 
66
        case AF_INET:
 
67
                return (struct sockaddr *)&src->u.v4;
 
68
                break;
 
69
        case AF_INET6:
 
70
                return (struct sockaddr *)&src->u.v6;
 
71
                break;
 
72
        default:
 
73
                return NULL;    /* "can't happen" */
 
74
                break;
 
75
        }
 
76
}
 
77
 
 
78
/*
 
79
 - sockaddrlenof - get length of the sockaddr hiding inside an ip_address
 
80
 */
 
81
size_t                          /* 0 for error */
 
82
sockaddrlenof(src)
 
83
const ip_address *src;
 
84
{
 
85
        switch (src->u.v4.sin_family) {
 
86
        case AF_INET:
 
87
                return sizeof(src->u.v4);
 
88
                break;
 
89
        case AF_INET6:
 
90
                return sizeof(src->u.v6);
 
91
                break;
 
92
        default:
 
93
                return 0;
 
94
                break;
 
95
        }
 
96
}