~ubuntu-branches/ubuntu/oneiric/openvpn/oneiric

« back to all changes in this revision

Viewing changes to debian/patches/lladdr-is-not-ip.patch

  • Committer: Bazaar Package Importer
  • Author(s): Thierry Carrez
  • Date: 2008-10-07 16:30:44 UTC
  • mfrom: (1.1.11 upstream) (10.1.1 lenny)
  • Revision ID: james.westby@ubuntu.com-20081007163044-ixx04wg588z1972e
Tags: 2.1~rc11-1ubuntu1
* Merge with Debian (LP: #279655), remaining diffs:
  - debian/openvpn.init.d: Added 'status' action to init script, show
    per-VPN result messages and add "--script-security 2" by default for
    backwards compatibility
  - debian/control: Added lsb-base>=3.2-14 depend to allow status_of_proc()
* Fixes regression when calling commands with arguments (LP: #277447)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
Index: openvpn-2.1_rc11/options.c
 
2
===================================================================
 
3
--- openvpn-2.1_rc11.orig/options.c     2008-09-18 00:28:30.813005586 +0200
 
4
+++ openvpn-2.1_rc11/options.c  2008-09-18 00:29:16.041367039 +0200
 
5
@@ -3436,11 +3436,11 @@
 
6
   else if (streq (p[0], "lladdr") && p[1])
 
7
     {
 
8
       VERIFY_PERMISSION (OPT_P_UP);
 
9
-      if (ip_addr_dotted_quad_safe (p[1])) /* FQDN -- IP address only */
 
10
+      if (mac_addr_safe (p[1])) /* MAC address only */
 
11
        options->lladdr = p[1];
 
12
       else
 
13
        {
 
14
-         msg (msglevel, "lladdr parm '%s' must be an IP address", p[1]);
 
15
+         msg (msglevel, "lladdr parm '%s' must be an MAC address", p[1]);
 
16
          goto err;
 
17
        }
 
18
     }
 
19
Index: openvpn-2.1_rc11/socket.c
 
20
===================================================================
 
21
--- openvpn-2.1_rc11.orig/socket.c      2008-09-18 00:28:36.304471508 +0200
 
22
+++ openvpn-2.1_rc11/socket.c   2008-09-18 00:29:16.044367597 +0200
 
23
@@ -294,6 +294,47 @@
 
24
   }
 
25
 }
 
26
 
 
27
+bool
 
28
+mac_addr_safe (const char *mac_addr)
 
29
+{
 
30
+  /* verify non-NULL */
 
31
+  if (!mac_addr)
 
32
+    return false;
 
33
+
 
34
+  /* verify length is within limits */
 
35
+  if (strlen (mac_addr) > 17)
 
36
+    return false;
 
37
+
 
38
+  /* verify that all chars are either alphanumeric or ':' and that no
 
39
+     alphanumeric substring is greater than 2 chars */
 
40
+  {
 
41
+    int nnum = 0;
 
42
+    const char *p = mac_addr;
 
43
+    int c;
 
44
+
 
45
+    while ((c = *p++))
 
46
+      {
 
47
+       if ( (c >= '0' && c <= '9') || (c >= 'a' && c <= 'f') || (c >= 'A' && c <= 'F') )
 
48
+         {
 
49
+           ++nnum;
 
50
+           if (nnum > 2)
 
51
+             return false;
 
52
+         }
 
53
+       else if (c == ':')
 
54
+         {
 
55
+           nnum = 0;
 
56
+         }
 
57
+       else
 
58
+         return false;
 
59
+      }
 
60
+  }
 
61
+
 
62
+  /* error-checking is left to script invoked in lladdr.c */
 
63
+  return true;
 
64
+
 
65
+}
 
66
+
 
67
+
 
68
 static bool
 
69
 dns_addr_safe (const char *addr)
 
70
 {
 
71
Index: openvpn-2.1_rc11/socket.h
 
72
===================================================================
 
73
--- openvpn-2.1_rc11.orig/socket.h      2008-09-18 00:28:41.083135754 +0200
 
74
+++ openvpn-2.1_rc11/socket.h   2008-09-18 00:29:16.046367039 +0200
 
75
@@ -399,6 +399,7 @@
 
76
 
 
77
 /* integrity validation on pulled options */
 
78
 bool ip_addr_dotted_quad_safe (const char *dotted_quad);
 
79
+bool mac_addr_safe (const char *mac_addr);
 
80
 bool ip_or_dns_addr_safe (const char *addr, const bool allow_fqdn);
 
81
 
 
82
 socket_descriptor_t create_socket_tcp (void);