(/home/sate/Testcases/c/cve/wireshark-1.2.0/epan/dissectors/packet-kismet.c) |
| |
| 58 | | | dissect_kismet(tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree) |
| 59 | | | { |
| 60 | | | gboolean is_request; |
| 61 | | | gboolean is_continuation; |
| 62 | | | proto_tree *kismet_tree=NULL, *reqresp_tree=NULL; |
| 63 | | | proto_item *ti; |
| 64 | | | proto_item *tmp_item; |
| 65 | | | gint offset = 0; |
| 66 | | | const guchar *line; |
| 67 | | | gint next_offset; |
| 68 | | | int linelen; |
| 69 | | | int tokenlen; |
| 70 | | | int i; |
| 71 | | | const guchar *next_token; |
| 72 | | | |
| 73 | | | |
| 74 | | | |
| 75 | | | |
| 76 | | | |
| 77 | | | |
| 78 | | | |
| 79 | | | |
| 80 | [+] | | linelen = tvb_find_line_end(tvb, offset, -1, &next_offset, FALSE); |
 |
| 81 | | | line = tvb_get_ptr(tvb, offset, linelen); |
| 82 | | | |
| 83 | | | |
| 84 | | | |
| 85 | | | |
| 86 | | | |
| 87 | | | if (linelen < 8) { |
Event 15:
Taking false branch. linelen < 8 evaluates to false.
hide
|
|
| 88 | | | |
| 89 | | | |
| 90 | | | |
| 91 | | | return FALSE; |
| 92 | | | } else { |
| 93 | | | for (i = 0; i < 8; ++i) { |
| 94 | | | |
| 95 | | | |
| 96 | | | |
| 97 | | | if (line[i] < 32 || line[i] > 128) |
| 98 | | | return FALSE; |
| 99 | | | } |
| 100 | | | } |
| 101 | | | |
| 102 | | | |
| 103 | | | |
| 104 | | | |
| 105 | [+] | | if (check_col(pinfo->cinfo, COL_PROTOCOL)) |
 |
| 106 | | | col_set_str(pinfo->cinfo, COL_PROTOCOL, "kismet"); |
| 107 | | | |
| 108 | | | |
| 109 | | | |
| 110 | | | |
| 111 | | | if (pinfo->match_port == pinfo->destport) { |
Event 19:
Taking false branch. pinfo->match_port == pinfo->destport evaluates to false.
hide
|
|
| 112 | | | is_request = TRUE; |
| 113 | | | is_continuation = FALSE; |
| 114 | | | } else { |
| 115 | | | is_request = FALSE; |
| 116 | [+] | | is_continuation = response_is_continuation (line); |
 |
| 117 | | | } |
| 118 | | | |
| 119 | [+] | | if (check_col(pinfo->cinfo, COL_INFO)) { |
 |
| 120 | | | |
| 121 | | | |
| 122 | | | |
| 123 | | | |
| 124 | | | |
| 125 | | | |
| 126 | | | if (is_continuation) |
| 127 | | | col_set_str(pinfo->cinfo, COL_INFO, "Continuation"); |
| 128 | | | else |
| 129 | | | col_add_fstr(pinfo->cinfo, COL_INFO, "%s: %s", |
| 130 | | | is_request ? "Request" : "Response", |
| 131 | | | format_text(line, linelen)); |
| 132 | | | } |
| 133 | | | |
| 134 | | | if (tree) { |
Event 23:
Taking true branch. tree evaluates to true.
hide
|
|
| 135 | | | ti = proto_tree_add_item(tree, proto_kismet, tvb, offset, -1, FALSE); |
| 136 | | | kismet_tree = proto_item_add_subtree(ti, ett_kismet); |
| 137 | | | } |
| 138 | | | |
| 139 | | | if (is_continuation) { |
Event 24:
Skipping " if". is_continuation evaluates to false.
hide
|
|
| 140 | | | |
| 141 | | | |
| 142 | | | |
| 143 | | | call_dissector(data_handle, tvb, pinfo, kismet_tree); |
| 144 | | | return TRUE; |
| 145 | | | } |
| 146 | | | |
| 147 | | | if (is_request) { |
Event 25:
Taking false branch. is_request evaluates to false.
hide
|
|
| 148 | | | tmp_item = proto_tree_add_boolean(kismet_tree, |
| 149 | | | hf_kismet_request, tvb, 0, 0, TRUE); |
| 150 | | | } else { |
| 151 | | | tmp_item = proto_tree_add_boolean(kismet_tree, |
| 152 | | | hf_kismet_response, tvb, 0, 0, TRUE); |
Event 26:
!0 evaluates to true.
hide
|
|
| 153 | | | } |
| 154 | | | PROTO_ITEM_SET_GENERATED (tmp_item);
x /home/sate/Testcases/c/cve/wireshark-1.2.0/epan/proto.h |
| |
325 | #define PROTO_ITEM_SET_GENERATED(proto_item) \ |
326 | ((proto_item) ? FI_SET_FLAG((proto_item)->finfo, FI_GENERATED) : 0) |
| |
x /home/sate/Testcases/c/cve/wireshark-1.2.0/epan/proto.h |
| |
246 | #define FI_SET_FLAG(fi, flag) (fi->flags = fi->flags | flag) |
| |
|
Event 27:
tmp_item evaluates to true.
hide
|
|
| 155 | | | |
| 156 | [+] | | while (tvb_offset_exists(tvb, offset)) { |
 |
| 157 | | | |
| 158 | | | |
| 159 | | | |
| 160 | [+] | | linelen = tvb_find_line_end(tvb, offset, -1, &next_offset, FALSE); |
 |
| 161 | | | |
| 162 | | | if (linelen) { |
Event 38:
Taking true branch. linelen evaluates to true.
hide
|
|
| 163 | | | |
| 164 | | | |
| 165 | | | |
| 166 | | | ti = proto_tree_add_text(kismet_tree, tvb, offset, |
| 167 | | | next_offset - offset, "%s", |
| 168 | | | tvb_format_text(tvb, offset, |
| 169 | | | next_offset - offset - 1)); |
| 170 | | | reqresp_tree = proto_item_add_subtree(ti, ett_kismet_reqresp); |
| 171 | [+] | | tokenlen = get_token_len(line, line + linelen, &next_token); |
 |
| 172 | | | if (tokenlen != 0) { |
Event 41:
Taking true branch. tokenlen != 0 evaluates to true.
hide
|
|
| 173 | | | guint8 *reqresp; |
| 174 | | | reqresp = tvb_get_ephemeral_string(tvb, offset, tokenlen); |
| 175 | | | if (is_request) { |
Event 42:
Taking false branch. is_request evaluates to false.
hide
|
|
| 176 | | | |
| 177 | | | |
| 178 | | | |
| 179 | | | } else { |
| 180 | | | |
| 181 | | | |
| 182 | | | |
| 183 | | | |
| 184 | | | if (!strncmp(reqresp, "*KISMET", 7)) { |
Event 43:
Skipping " if". strncmp(reqresp, "*KISMET", 7) evaluates to true.
hide
|
|
| 185 | | | offset += (gint) (next_token - line); |
| 186 | | | linelen -= (int) (next_token - line); |
| 187 | | | line = next_token; |
| 188 | | | tokenlen = get_token_len(line, line + linelen, &next_token); |
| 189 | | | proto_tree_add_text(reqresp_tree, tvb, offset, |
| 190 | | | tokenlen, "Kismet version: %s", |
| 191 | | | format_text(line, tokenlen)); |
| 192 | | | |
| 193 | | | offset += (gint) (next_token - line); |
| 194 | | | linelen -= (int) (next_token - line); |
| 195 | | | line = next_token; |
| 196 | | | tokenlen = get_token_len(line, line + linelen, &next_token); |
| 197 | | | proto_tree_add_text(reqresp_tree, tvb, offset, |
| 198 | | | tokenlen, "Start time: %s", |
| 199 | | | format_text(line, tokenlen)); |
| 200 | | | |
| 201 | | | offset += (gint) (next_token - line); |
| 202 | | | linelen -= (int) (next_token - line); |
| 203 | | | line = next_token; |
| 204 | | | tokenlen = get_token_len(line, line + linelen, &next_token); |
| 205 | | | proto_tree_add_text(reqresp_tree, tvb, offset, |
| 206 | | | tokenlen, "Server name: %s", |
| 207 | | | format_text(line + 1, tokenlen - 2)); |
| 208 | | | |
| 209 | | | offset += (gint) (next_token - line); |
| 210 | | | linelen -= (int) (next_token - line); |
| 211 | | | line = next_token; |
| 212 | | | tokenlen = get_token_len(line, line + linelen, &next_token); |
| 213 | | | proto_tree_add_text(reqresp_tree, tvb, offset, |
| 214 | | | tokenlen, "Build revision: %s", |
| 215 | | | format_text(line, tokenlen)); |
| 216 | | | |
| 217 | | | offset += (gint) (next_token - line); |
| 218 | | | linelen -= (int) (next_token - line); |
| 219 | | | line = next_token; |
| 220 | | | tokenlen = get_token_len(line, line + linelen, &next_token); |
| 221 | | | proto_tree_add_text(reqresp_tree, tvb, offset, |
| 222 | | | tokenlen, "Unknown field: %s", |
| 223 | | | format_text(line, tokenlen)); |
| 224 | | | |
| 225 | | | offset += (gint) (next_token - line); |
| 226 | | | linelen -= (int) (next_token - line); |
| 227 | | | line = next_token; |
| 228 | | | tokenlen = get_token_len(line, line + linelen, &next_token); |
| 229 | | | proto_tree_add_text(reqresp_tree, tvb, offset, |
| 230 | | | tokenlen, |
| 231 | | | "Extended version string: %s", |
| 232 | | | format_text(line, tokenlen)); |
| 233 | | | } |
| 234 | | | |
| 235 | | | |
| 236 | | | |
| 237 | | | if (!strncmp(reqresp, "*TIME", 5)) { |
Event 44:
Taking true branch. strncmp(reqresp, "*TIME", 5) evaluates to false.
hide
|
|
| 238 | | | time_t t; |
| 239 | | | char *ptr; |
| 240 | | | |
| 241 | | | offset += (gint) (next_token - line); |
| 242 | | | linelen -= (int) (next_token - line); |
| 243 | | | line = next_token; |
| 244 | | | tokenlen = get_token_len(line, line + linelen, &next_token); |
| 245 | | | |
| 246 | | | |
| 247 | | | |
| 248 | | | |
| 249 | | | t = atoi(format_text (line, tokenlen)); |
| 250 | | | |
| 251 | | | |
| 252 | | | |
| 253 | | | |
| 254 | | | ptr = ctime(&t); |
Event 45:
ctime() returns NULL. - Dereferenced later, causing the null pointer dereference.
hide
Event 46:
ptr is set to ctime(&t), which evaluates to NULL. See related event 45.
hide
|
|
| 255 | | | |
| 256 | | | |
| 257 | | | |
| 258 | | | ptr[strlen(ptr) - 1] = 0; |
Event 47:
ptr, which evaluates to NULL, is passed to __builtin_strlen(). See related event 46.
hide
Null Pointer Dereference
The body of __builtin_strlen() dereferences ptr, but it is NULL. The issue can occur if the highlighted code executes. See related event 47. Show: All events | Only primary events |
|
| 259 | | | |
| 260 | | | proto_tree_add_text(reqresp_tree, tvb, offset, |
| 261 | | | tokenlen, "Time: %s", ptr); |
| 262 | | | } |
| 263 | | | } |
| 264 | | | |
| 265 | | | offset += (gint) (next_token - line); |
| 266 | | | linelen -= (int) (next_token - line); |
| 267 | | | line = next_token; |
| 268 | | | } |
| 269 | | | } |
| 270 | | | offset = next_offset; |
| |