summaryrefslogtreecommitdiff
blob: d1286b1dd5eff6ae1f339fe78b5dd597f95a4ce4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
--- snort-2.3.3.orig/src/log.c	2005-09-17 00:34:21.000000000 -0300
+++ snort-2.3.3/src/log.c	2005-09-17 00:47:50.000000000 -0300
@@ -1478,7 +1478,10 @@
                 {
                     for(j = 0; j < p->ip_options[i].len; j++)
                     {
-                        fprintf(fp, "%02X", p->ip_options[i].data[j]);
+                        if (p->ip_options[i].data)
+                            fprintf(fp, "%02X", p->ip_options[i].data[j]);
+                        else
+                            fprintf(fp, "%02X", 0);
                         
                         if((j % 2) == 0)
                             fprintf(fp, " ");
@@ -1522,7 +1525,8 @@
             case TCPOPT_MAXSEG:
                 bzero((char *) tmp, 5);
                 fwrite("MSS: ", 5, 1, fp);
-                memcpy(tmp, p->tcp_options[i].data, 2);
+                if (p->tcp_options[i].data)
+                    memcpy(tmp, p->tcp_options[i].data, 2);
                 fprintf(fp, "%u ", EXTRACT_16BITS(tmp));
                 break;
 
@@ -1535,15 +1539,20 @@
                 break;
 
             case TCPOPT_WSCALE:
-                fprintf(fp, "WS: %u ", p->tcp_options[i].data[0]);
+                if (p->tcp_options[i].data)
+                    fprintf(fp, "WS: %u ", p->tcp_options[i].data[0]);
+                else
+                    fprintf(fp, "WS: %u ", 0);
                 break;
 
             case TCPOPT_SACK:
                 bzero((char *) tmp, 5);
-                memcpy(tmp, p->tcp_options[i].data, 2);
+                if (p->tcp_options[i].data)
+                    memcpy(tmp, p->tcp_options[i].data, 2);
                 fprintf(fp, "Sack: %u@", EXTRACT_16BITS(tmp));
                 bzero((char *) tmp, 5);
-                memcpy(tmp, (p->tcp_options[i].data) + 2, 2);
+                if (p->tcp_options[i].data)
+                    memcpy(tmp, (p->tcp_options[i].data) + 2, 2);
                 fprintf(fp, "%u ", EXTRACT_16BITS(tmp));
                 break;
 
@@ -1553,40 +1562,47 @@
 
             case TCPOPT_ECHO:
                 bzero((char *) tmp, 5);
-                memcpy(tmp, p->tcp_options[i].data, 4);
+                if (p->tcp_options[i].data)
+                    memcpy(tmp, p->tcp_options[i].data, 4);
                 fprintf(fp, "Echo: %u ", EXTRACT_32BITS(tmp));
                 break;
 
             case TCPOPT_ECHOREPLY:
                 bzero((char *) tmp, 5);
-                memcpy(tmp, p->tcp_options[i].data, 4);
+                if (p->tcp_options[i].data)
+                    memcpy(tmp, p->tcp_options[i].data, 4);
                 fprintf(fp, "Echo Rep: %u ", EXTRACT_32BITS(tmp));
                 break;
 
             case TCPOPT_TIMESTAMP:
                 bzero((char *) tmp, 5);
-                memcpy(tmp, p->tcp_options[i].data, 4);
+                if (p->tcp_options[i].data)
+                    memcpy(tmp, p->tcp_options[i].data, 4);
                 fprintf(fp, "TS: %u ", EXTRACT_32BITS(tmp));
                 bzero((char *) tmp, 5);
-                memcpy(tmp, (p->tcp_options[i].data) + 4, 4);
+                if (p->tcp_options[i].data)
+                    memcpy(tmp, (p->tcp_options[i].data) + 4, 4);
                 fprintf(fp, "%u ", EXTRACT_32BITS(tmp));
                 break;
 
             case TCPOPT_CC:
                 bzero((char *) tmp, 5);
-                memcpy(tmp, p->tcp_options[i].data, 4);
+                if (p->tcp_options[i].data)
+                    memcpy(tmp, p->tcp_options[i].data, 4);
                 fprintf(fp, "CC %u ", EXTRACT_32BITS(tmp));
                 break;
 
             case TCPOPT_CCNEW:
                 bzero((char *) tmp, 5);
-                memcpy(tmp, p->tcp_options[i].data, 4);
+                if (p->tcp_options[i].data)
+                    memcpy(tmp, p->tcp_options[i].data, 4);
                 fprintf(fp, "CCNEW: %u ", EXTRACT_32BITS(tmp));
                 break;
 
             case TCPOPT_CCECHO:
                 bzero((char *) tmp, 5);
-                memcpy(tmp, p->tcp_options[i].data, 4);
+                if (p->tcp_options[i].data)
+                    memcpy(tmp, p->tcp_options[i].data, 4);
                 fprintf(fp, "CCECHO: %u ", EXTRACT_32BITS(tmp));
                 break;
 
@@ -1598,7 +1614,10 @@
 
                     for(j = 0; j < p->tcp_options[i].len; j++)
                     {
-                        fprintf(fp, "%02X", p->tcp_options[i].data[j]);
+                        if (p->tcp_options[i].data)
+                            fprintf(fp, "%02X", p->tcp_options[i].data[j]);
+                        else
+                            fprintf(fp, "%02X", 0);
                         
                         if((j % 2) == 0)
                             fprintf(fp, " ");