File tree 1 file changed +14
-2
lines changed
1 file changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -117,9 +117,21 @@ extern int32_t thiszone; /* seconds offset from gmt to local time */
117
117
* that "snapend - (l)" underflows.
118
118
*
119
119
* The check is for <= rather than < because "l" might be 0.
120
+ *
121
+ * We cast the pointers to uintptr_t to make sure that the compiler
122
+ * doesn't optimize away any of these tests (which it is allowed to
123
+ * do, as adding an integer to, or subtracting an integer from, a
124
+ * pointer assumes that the pointer is a pointer to an element of an
125
+ * array and that the result of the addition or subtraction yields a
126
+ * pointer to another member of the array, so that, for example, if
127
+ * you subtract a positive integer from a pointer, the result is
128
+ * guaranteed to be less than the original pointer value). See
129
+ *
130
+ * http://www.kb.cert.org/vuls/id/162289
120
131
*/
121
- #define TTEST2 (var , l ) (snapend - (l) <= snapend && \
122
- (const u_char *)&(var) <= snapend - (l))
132
+ #define TTEST2 (var , l ) \
133
+ ((uintptr_t)snapend - (l) <= (uintptr_t)snapend && \
134
+ (uintptr_t)&(var) <= (uintptr_t)snapend - (l))
123
135
124
136
/* True if "var" was captured */
125
137
#define TTEST (var ) TTEST2(var, sizeof(var))
You can’t perform that action at this time.
0 commit comments