(/home/sate/Testcases/c/cve/wireshark-1.2.0/wiretap/radcom.c) |
| |
| 102 | | | int radcom_open(wtap *wth, int *err, gchar **err_info) |
| 103 | | | { |
| 104 | | | int bytes_read; |
| 105 | | | guint8 r_magic[8], t_magic[11], search_encap[7]; |
| 106 | | | struct frame_date start_date; |
| 107 | | | guint32 sec; |
| 108 | | | struct tm tm; |
| 109 | | | |
| 110 | | | |
| 111 | | | errno = WTAP_ERR_CANT_READ; |
| 112 | | | bytes_read = file_read(r_magic, 1, 8, wth->fh);
x /home/sate/Testcases/c/cve/wireshark-1.2.0/wiretap/file_wrappers.h |
| |
36 | #define file_read(buf, bsize, count, file) gzread((file),(buf),(unsigned)((count)*(bsize))) |
| |
|
| 113 | | | if (bytes_read != 8) { |
| 114 | | | *err = file_error(wth->fh); |
| 115 | | | if (*err != 0) |
| 116 | | | return -1; |
| 117 | | | return 0; |
| 118 | | | } |
| 119 | | | |
| 120 | | | |
| 121 | | | |
| 122 | | | |
| 123 | | | |
| 124 | | | r_magic[1] = 0xD2; |
| 125 | | | r_magic[2] = 0x00; |
| 126 | | | if (memcmp(r_magic, radcom_magic, 8) != 0) { |
| 127 | | | return 0; |
| 128 | | | } |
| 129 | | | |
| 130 | | | |
| 131 | | | |
| 132 | | | wth->data_offset = 8; |
| 133 | | | errno = WTAP_ERR_CANT_READ; |
Useless Assignment
This code assigns the variable the same value it already had. |
|
| 134 | | | bytes_read = file_read(t_magic, 1, 11, wth->fh);
x /home/sate/Testcases/c/cve/wireshark-1.2.0/wiretap/file_wrappers.h |
| |
36 | #define file_read(buf, bsize, count, file) gzread((file),(buf),(unsigned)((count)*(bsize))) |
| |
|
| 135 | | | if (bytes_read != 11) { |
| 136 | | | *err = file_error(wth->fh); |
| 137 | | | if (*err != 0) |
| 138 | | | return -1; |
| 139 | | | return 0; |
| 140 | | | } |
| 141 | | | while (memcmp(t_magic, active_time_magic, 11) != 0) |
| 142 | | | { |
| 143 | | | if (file_seek(wth->fh, -10, SEEK_CUR, err) == -1)
x /usr/include/stdio.h |
| |
142 | #define SEEK_CUR 1 /* Seek from current position. */ |
| |
|
| 144 | | | return -1; |
| 145 | | | wth->data_offset += 1; |
| 146 | | | errno = WTAP_ERR_CANT_READ; |
| 147 | | | bytes_read = file_read(t_magic, 1, 11, wth->fh);
x /home/sate/Testcases/c/cve/wireshark-1.2.0/wiretap/file_wrappers.h |
| |
36 | #define file_read(buf, bsize, count, file) gzread((file),(buf),(unsigned)((count)*(bsize))) |
| |
|
| 148 | | | if (bytes_read != 11) { |
| 149 | | | *err = file_error(wth->fh); |
| 150 | | | if (*err != 0) |
| 151 | | | return -1; |
| 152 | | | return 0; |
| 153 | | | } |
| 154 | | | } |
| 155 | | | if (file_seek(wth->fh, -43, SEEK_CUR, err) == -1) return -1;
x /usr/include/stdio.h |
| |
142 | #define SEEK_CUR 1 /* Seek from current position. */ |
| |
|
| 156 | | | wth->data_offset -= 32; |
| 157 | | | |
| 158 | | | |
| 159 | | | errno = WTAP_ERR_CANT_READ; |
| 160 | | | bytes_read = file_read(&start_date, 1, sizeof(struct frame_date),
x /home/sate/Testcases/c/cve/wireshark-1.2.0/wiretap/file_wrappers.h |
| |
36 | #define file_read(buf, bsize, count, file) gzread((file),(buf),(unsigned)((count)*(bsize))) |
| |
|
| 161 | | | wth->fh); |
| 162 | | | if (bytes_read != sizeof(struct frame_date)) { |
| 163 | | | *err = file_error(wth->fh); |
| 164 | | | if (*err != 0) |
| 165 | | | return -1; |
| 166 | | | return 0; |
| 167 | | | } |
| 168 | | | wth->data_offset += sizeof(struct frame_date); |
| 169 | | | |
| 170 | | | |
| 171 | | | wth->file_type = WTAP_FILE_RADCOM; |
| 172 | | | wth->subtype_read = radcom_read; |
| 173 | | | wth->subtype_seek_read = radcom_seek_read; |
| 174 | | | wth->snapshot_length = 0; |
| 175 | | | wth->tsprecision = WTAP_FILE_TSPREC_USEC; |
| 176 | | | |
| 177 | | | tm.tm_year = pletohs(&start_date.year)-1900;
x /home/sate/Testcases/c/cve/wireshark-1.2.0/wiretap/wtap-int.h |
| |
373 | #define pletohs(p) ((guint16) \ |
374 | ((guint16)*((const guint8 *)(p)+1)<<8| \ |
375 | (guint16)*((const guint8 *)(p)+0)<<0)) |
| |
|
| 178 | | | tm.tm_mon = start_date.month-1; |
| 179 | | | tm.tm_mday = start_date.day; |
| 180 | | | sec = pletohl(&start_date.sec);
x /home/sate/Testcases/c/cve/wireshark-1.2.0/wiretap/wtap-int.h |
| |
386 | #define pletohl(p) ((guint32)*((const guint8 *)(p)+3)<<24| \ |
387 | (guint32)*((const guint8 *)(p)+2)<<16| \ |
388 | (guint32)*((const guint8 *)(p)+1)<<8| \ |
389 | (guint32)*((const guint8 *)(p)+0)<<0) |
| |
|
| 181 | | | tm.tm_hour = sec/3600; |
| 182 | | | tm.tm_min = (sec%3600)/60; |
| 183 | | | tm.tm_sec = sec%60; |
| 184 | | | tm.tm_isdst = -1; |
| 185 | | | |
| 186 | | | if (file_seek(wth->fh, sizeof(struct frame_date), SEEK_CUR, err) == -1)
x /usr/include/stdio.h |
| |
142 | #define SEEK_CUR 1 /* Seek from current position. */ |
| |
|
| 187 | | | return -1; |
| 188 | | | wth->data_offset += sizeof(struct frame_date); |
| 189 | | | |
| 190 | | | errno = WTAP_ERR_CANT_READ; |
| 191 | | | bytes_read = file_read(search_encap, 1, 4, wth->fh);
x /home/sate/Testcases/c/cve/wireshark-1.2.0/wiretap/file_wrappers.h |
| |
36 | #define file_read(buf, bsize, count, file) gzread((file),(buf),(unsigned)((count)*(bsize))) |
| |
|
| 192 | | | if (bytes_read != 4) { |
| 193 | | | goto read_error; |
| 194 | | | } |
| 195 | | | wth->data_offset += 4; |
| 196 | | | while (memcmp(encap_magic, search_encap, 4)) { |
| 197 | | | if (file_seek(wth->fh, -3, SEEK_CUR, err) == -1)
x /usr/include/stdio.h |
| |
142 | #define SEEK_CUR 1 /* Seek from current position. */ |
| |
|
| 198 | | | return -1; |
| 199 | | | wth->data_offset -= 3; |
| 200 | | | errno = WTAP_ERR_CANT_READ; |
| 201 | | | bytes_read = file_read(search_encap, 1, 4, wth->fh);
x /home/sate/Testcases/c/cve/wireshark-1.2.0/wiretap/file_wrappers.h |
| |
36 | #define file_read(buf, bsize, count, file) gzread((file),(buf),(unsigned)((count)*(bsize))) |
| |
|
| 202 | | | if (bytes_read != 4) { |
| 203 | | | goto read_error; |
| 204 | | | } |
| 205 | | | wth->data_offset += 4; |
| 206 | | | } |
| 207 | | | if (file_seek(wth->fh, 12, SEEK_CUR, err) == -1)
x /usr/include/stdio.h |
| |
142 | #define SEEK_CUR 1 /* Seek from current position. */ |
| |
|
| 208 | | | return -1; |
| 209 | | | wth->data_offset += 12; |
| 210 | | | errno = WTAP_ERR_CANT_READ; |
| 211 | | | bytes_read = file_read(search_encap, 1, 4, wth->fh);
x /home/sate/Testcases/c/cve/wireshark-1.2.0/wiretap/file_wrappers.h |
| |
36 | #define file_read(buf, bsize, count, file) gzread((file),(buf),(unsigned)((count)*(bsize))) |
| |
|
| 212 | | | if (bytes_read != 4) { |
| 213 | | | goto read_error; |
| 214 | | | } |
| 215 | | | wth->data_offset += 4; |
| 216 | | | if (memcmp(search_encap, "LAPB", 4) == 0) |
| 217 | | | wth->file_encap = WTAP_ENCAP_LAPB; |
| 218 | | | else if (memcmp(search_encap, "Ethe", 4) == 0) |
| 219 | | | wth->file_encap = WTAP_ENCAP_ETHERNET; |
| 220 | | | else if (memcmp(search_encap, "ATM/", 4) == 0) |
| 221 | | | wth->file_encap = WTAP_ENCAP_ATM_RFC1483; |
| 222 | | | else { |
| 223 | | | *err = WTAP_ERR_UNSUPPORTED_ENCAP; |
| 224 | | | *err_info = g_strdup_printf("radcom: network type \"%.4s\" unknown", search_encap); |
| 225 | | | return -1; |
| 226 | | | } |
| 227 | | | |
| 228 | | | |
| 229 | | | |
| 230 | | | |
| 231 | | | |
| 232 | | | |
| 233 | | | |
| 234 | | | |
| 235 | | | |
| 236 | | | |
| 237 | | | |
| 238 | | | |
| 239 | | | |
| 240 | | | |
| 241 | | | |
| 242 | | | |
| 243 | | | |
| 244 | | | |
| 245 | | | if (wth->file_encap == WTAP_ENCAP_ETHERNET) { |
| 246 | | | if (file_seek(wth->fh, 294, SEEK_CUR, err) == -1)
x /usr/include/stdio.h |
| |
142 | #define SEEK_CUR 1 /* Seek from current position. */ |
| |
|
| 247 | | | return -1; |
| 248 | | | wth->data_offset += 294; |
| 249 | | | } else if (wth->file_encap == WTAP_ENCAP_LAPB) { |
| 250 | | | if (file_seek(wth->fh, 297, SEEK_CUR, err) == -1)
x /usr/include/stdio.h |
| |
142 | #define SEEK_CUR 1 /* Seek from current position. */ |
| |
|
| 251 | | | return -1; |
| 252 | | | wth->data_offset += 297; |
| 253 | | | } else if (wth->file_encap == WTAP_ENCAP_ATM_RFC1483) { |
| 254 | | | if (file_seek(wth->fh, 504, SEEK_CUR, err) == -1)
x /usr/include/stdio.h |
| |
142 | #define SEEK_CUR 1 /* Seek from current position. */ |
| |
|
| 255 | | | return -1; |
| 256 | | | wth->data_offset += 504; |
| 257 | | | } |
| 258 | | | |
| 259 | | | return 1; |
| 260 | | | |
| 261 | | | read_error: |
| 262 | | | *err = file_error(wth->fh); |
| 263 | | | if (*err != 0) |
| 264 | | | return -1; |
| 265 | | | return 0; |
| 266 | | | } |
| |