FreeBSD Bugzilla – Attachment 11562 Details for
Bug 22730
tcpslice doesn't handle long file offsets
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
file.diff
file.diff (text/plain), 5.71 KB, created by
dc
on 2000-11-10 02:50:01 UTC
(
hide
)
Description:
file.diff
Filename:
MIME Type:
Creator:
dc
Created:
2000-11-10 02:50:01 UTC
Size:
5.71 KB
patch
obsolete
>Index: gwtm2secs.c >=================================================================== >RCS file: /home/cvs/freebsd/src/usr.sbin/tcpdump/tcpslice/gwtm2secs.c,v >retrieving revision 1.4 >diff -u -r1.4 gwtm2secs.c >--- gwtm2secs.c 1999/08/28 05:11:32 1.4 >+++ gwtm2secs.c 2000/11/10 01:28:34 >@@ -47,10 +47,12 @@ > * distinguishes them, since we can't represent any time < 1970. > */ > if ( year < 100 ) >+ { > if ( year >= 70 ) > year += 1900; > else > year += 2000; >+ } > > days = 0; > for ( i = 1970; i < year; ++i ) >Index: search.c >=================================================================== >RCS file: /home/cvs/freebsd/src/usr.sbin/tcpdump/tcpslice/search.c,v >retrieving revision 1.4 >diff -u -r1.4 search.c >--- search.c 1999/08/28 05:11:32 1.4 >+++ search.c 2000/11/10 01:28:34 >@@ -378,26 +378,25 @@ > t1->tv_usec < t2->tv_usec); > } > >- > /* Given two timestamps on either side of desired_time and their positions, > * returns the interpolated position of the desired_time packet. Returns a > * negative value if the desired_time is outside the given range. > */ > >-static long >-interpolated_position( struct timeval *min_time, long min_pos, >- struct timeval *max_time, long max_pos, >+static off_t >+interpolated_position( struct timeval *min_time, off_t min_pos, >+ struct timeval *max_time, off_t max_pos, > struct timeval *desired_time ) > { > double full_span = timeval_diff( max_time, min_time ); > double desired_span = timeval_diff( desired_time, min_time ); >- long full_span_pos = max_pos - min_pos; >+ off_t full_span_pos = max_pos - min_pos; > double fractional_offset = desired_span / full_span; > > if ( fractional_offset < 0.0 || fractional_offset > 1.0 ) > return -1; > >- return min_pos + (long) (fractional_offset * (double) full_span_pos); >+ return min_pos + (off_t) (fractional_offset * (double) full_span_pos); > } > > >@@ -412,14 +411,14 @@ > { > struct pcap_pkthdr hdr; > const u_char *buf; >- long pos; >+ off_t pos; > int status; > > for ( ; ; ) > { > struct timeval *timestamp; > >- pos = ftell( pcap_file( p ) ); >+ pos = ftello( pcap_file( p ) ); > buf = pcap_next( p, &hdr ); > > if ( buf == 0 ) >@@ -443,13 +442,12 @@ > } > } > >- if ( fseek( pcap_file( p ), pos, 0 ) < 0 ) >- error( "fseek() failed in read_up_to()" ); >+ if ( fseeko( pcap_file( p ), pos, 0 ) < 0 ) >+ error( "fseeko() failed in read_up_to()" ); > > return (status); > } > >- > /* Positions the sf_readfile stream so that the next sf_read() will > * return the first packet with a time greater than or equal to > * desired_time. desired_time must be greater than min_time and less >@@ -466,15 +464,15 @@ > > int > sf_find_packet( pcap_t *p, >- struct timeval *min_time, long min_pos, >- struct timeval *max_time, long max_pos, >+ struct timeval *min_time, off_t min_pos, >+ struct timeval *max_time, off_t max_pos, > struct timeval *desired_time ) > { > int status = 1; > struct timeval min_time_copy, max_time_copy; > u_int num_bytes = MAX_BYTES_FOR_DEFINITE_HEADER; > int num_bytes_read; >- long desired_pos, present_pos; >+ off_t desired_pos, present_pos; > u_char *buf, *hdrpos; > struct pcap_pkthdr hdr; > >@@ -501,7 +499,7 @@ > break; > } > >- present_pos = ftell( pcap_file( p ) ); >+ present_pos = ftello( pcap_file( p ) ); > > if ( present_pos <= desired_pos && > desired_pos - present_pos < STRAIGHT_SCAN_THRESHOLD ) >@@ -517,8 +515,8 @@ > if ( desired_pos < min_pos ) > desired_pos = min_pos; > >- if ( fseek( pcap_file( p ), desired_pos, 0 ) < 0 ) >- error( "fseek() failed in sf_find_packet()" ); >+ if ( fseeko( pcap_file( p ), desired_pos, 0 ) < 0 ) >+ error( "fseeko() failed in sf_find_packet()" ); > > num_bytes_read = > fread( (char *) buf, 1, num_bytes, pcap_file( p ) ); >@@ -540,8 +538,8 @@ > desired_pos += (hdrpos - buf); > > /* Seek to the beginning of the header. */ >- if ( fseek( pcap_file( p ), desired_pos, 0 ) < 0 ) >- error( "fseek() failed in sf_find_packet()" ); >+ if ( fseeko( pcap_file( p ), desired_pos, 0 ) < 0 ) >+ error( "fseeko() failed in sf_find_packet()" ); > > if ( sf_timestamp_less_than( &hdr.ts, desired_time ) ) > { /* too early in the file */ >Index: tcpslice.c >=================================================================== >RCS file: /home/cvs/freebsd/src/usr.sbin/tcpdump/tcpslice/tcpslice.c,v >retrieving revision 1.10 >diff -u -r1.10 tcpslice.c >--- tcpslice.c 2000/05/28 15:06:45 1.10 >+++ tcpslice.c 2000/11/10 01:28:34 >@@ -451,7 +451,7 @@ > extract_slice(char filename[], char write_file_name[], > struct timeval *start_time, struct timeval *stop_time) > { >- long start_pos, stop_pos; >+ off_t start_pos, stop_pos; > struct timeval file_start_time, file_stop_time; > struct pcap_pkthdr hdr; > pcap_t *p; >@@ -462,7 +462,7 @@ > error( "bad tcpdump file %s: %s", filename, errbuf ); > > snaplen = pcap_snapshot( p ); >- start_pos = ftell( pcap_file( p ) ); >+ start_pos = ftello( pcap_file( p ) ); > > if ( ! dumper ) > { >@@ -483,7 +483,7 @@ > error( "problems finding end packet of file %s", > filename ); > >- stop_pos = ftell( pcap_file( p ) ); >+ stop_pos = ftello( pcap_file( p ) ); > > > /* sf_find_packet() requires that the time it's passed as its last >Index: tcpslice.h >=================================================================== >RCS file: /home/cvs/freebsd/src/usr.sbin/tcpdump/tcpslice/tcpslice.h,v >retrieving revision 1.1 >diff -u -r1.1 tcpslice.h >--- tcpslice.h 1995/03/08 12:53:41 1.1 >+++ tcpslice.h 2000/11/10 01:28:34 >@@ -52,8 +52,8 @@ > struct timeval *last_timestamp ); > int sf_timestamp_less_than( struct timeval *t1, struct timeval *t2 ); > int sf_find_packet( struct pcap *p, >- struct timeval *min_time, long min_pos, >- struct timeval *max_time, long max_pos, >+ struct timeval *min_time, off_t min_pos, >+ struct timeval *max_time, off_t max_pos, > struct timeval *desired_time ); > > void error(const char *fmt, ...);
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 22730
: 11562