~ubuntu-branches/ubuntu/maverick/squid3/maverick-updates

« back to all changes in this revision

Viewing changes to debian/patches/16-CVE-2010-3072.dpatch

  • Committer: Bazaar Package Importer
  • Author(s): Alessio Treglia
  • Date: 2010-09-20 15:53:45 UTC
  • mfrom: (21.2.2 sid)
  • Revision ID: james.westby@ubuntu.com-20100920155345-dmbf0s6ww02pthim
Tags: 3.1.6-1.1ubuntu1
* Merge with Debian unstable, Ubuntu remaining changes:
  - Provide ufw profile.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#! /bin/sh /usr/share/dpatch/dpatch-run
 
2
 
 
3
@DPATCH@
 
4
--- ../old/squid3-3.1.6/src/SquidString.h       2010-08-02 00:01:39.000000000 +1000
 
5
+++ squid3-3.1.6/src/SquidString.h      2010-09-13 17:00:17.000000000 +1000
 
6
@@ -167,6 +167,8 @@
 
7
     void allocBuffer(size_type sz);
 
8
     void setBuffer(char *buf, size_type sz);
 
9
 
 
10
+    _SQUID_INLINE_ bool nilCmp(bool, bool, int &) const;
 
11
+
 
12
     /* never reference these directly! */
 
13
     size_type size_; /* buffer size; 64K limit */
 
14
 
 
15
--- ../old/squid3-3.1.6/src/String.cci  2010-08-02 00:01:37.000000000 +1000
 
16
+++ squid3-3.1.6/src/String.cci 2010-09-13 17:05:43.000000000 +1000
 
17
@@ -88,19 +88,31 @@
 
18
 }
 
19
 
 
20
 
 
21
-int
 
22
-String::cmp (char const *aString) const
 
23
+/// compare NULL and empty strings because str*cmp() may fail on NULL strings
 
24
+/// and because we need to return consistent results for strncmp(count == 0).
 
25
+bool
 
26
+String::nilCmp(const bool thisIsNilOrEmpty, const bool otherIsNilOrEmpty, int &result) const
 
27
 {
 
28
-    /* strcmp fails on NULLS */
 
29
+    if (!thisIsNilOrEmpty && !otherIsNilOrEmpty)
 
30
+        return false; // result does not matter
 
31
 
 
32
-    if (size() == 0 && (aString == NULL || aString[0] == '\0'))
 
33
-        return 0;
 
34
+    if (thisIsNilOrEmpty && otherIsNilOrEmpty)
 
35
+        result = 0;
 
36
+    else if (thisIsNilOrEmpty)
 
37
+        result = -1;
 
38
+    else // otherIsNilOrEmpty
 
39
+        result = +1;
 
40
+
 
41
+    return true;
 
42
+}
 
43
 
 
44
-    if (size() == 0)
 
45
-        return -1;
 
46
 
 
47
-    if (aString == NULL || aString[0] == '\0')
 
48
-        return 1;
 
49
+int
 
50
+String::cmp (char const *aString) const
 
51
+{
 
52
+    int result = 0;
 
53
+    if (nilCmp(!size(), (!aString || !*aString), result))
 
54
+        return result;
 
55
 
 
56
     return strcmp(termedBuf(), aString);
 
57
 }
 
58
@@ -108,19 +120,10 @@
 
59
 int
 
60
 String::cmp (char const *aString, String::size_type count) const
 
61
 {
 
62
-    /* always the same at length 0 */
 
63
-
 
64
-    if (count == 0)
 
65
-        return 0;
 
66
+    int result = 0;
 
67
+    if (nilCmp((!size() || !count), (!aString || !*aString || !count), result))
 
68
+        return result;
 
69
 
 
70
-    if (size() == 0 && (aString == NULL || aString[0] == '\0'))
 
71
-        return 0;
 
72
-
 
73
-    if (size() == 0)
 
74
-        return -1;
 
75
-
 
76
-    if (aString == NULL || aString[0] == '\0')
 
77
-        return 1;
 
78
 
 
79
     return strncmp(termedBuf(), aString, count);
 
80
 }
 
81
@@ -128,16 +131,10 @@
 
82
 int
 
83
 String::cmp (String const &aString) const
 
84
 {
 
85
-    /* strcmp fails on NULLS */
 
86
-
 
87
-    if (size() == 0 && aString.size() == 0)
 
88
-        return 0;
 
89
-
 
90
-    if (size() == 0)
 
91
-        return -1;
 
92
+    int result = 0;
 
93
+    if (nilCmp(!size(), !aString.size(), result))
 
94
+        return result;
 
95
 
 
96
-    if (aString.size() == 0)
 
97
-        return 1;
 
98
 
 
99
     return strcmp(termedBuf(), aString.termedBuf());
 
100
 }
 
101
@@ -145,12 +142,22 @@
 
102
 int
 
103
 String::caseCmp(char const *aString) const
 
104
 {
 
105
+    int result = 0;
 
106
+    if (nilCmp(!size(), (!aString || !*aString), result))
 
107
+        return result;
 
108
+
 
109
+
 
110
     return strcasecmp(termedBuf(), aString);
 
111
 }
 
112
 
 
113
 int
 
114
 String::caseCmp(char const *aString, String::size_type count) const
 
115
 {
 
116
+    int result = 0;
 
117
+    if (nilCmp((!size() || !count), (!aString || !*aString || !count), result))
 
118
+        return result;
 
119
+
 
120
+
 
121
     return strncasecmp(termedBuf(), aString, count);
 
122
 }
 
123