View | Details | Raw Unified | Return to bug 150176
Collapse All | Expand All

(-)b/pcap-bpf.c (-4 / +23 lines)
Lines 955-968 pcap_read_bpf(pcap_t *p, int cnt, pcap_handler callback, u_char *user) Link Here
955
		 * processed so far.
955
		 * processed so far.
956
		 */
956
		 */
957
		if (p->break_loop) {
957
		if (p->break_loop) {
958
			p->bp = bp;
959
			p->cc = ep - bp;
960
			/*
961
			 * ep is set based on the return value of read(),
962
			 * but read() from a BPF device doesn't necessarily
963
			 * return a value that's a multiple of the alignment
964
			 * value for BPF_WORDALIGN().  However, whenever we
965
			 * increment bp, we round up the increment value by
966
			 * a value rounded up by BPF_WORDALIGN(), so we
967
			 * could increment bp past ep after processing the
968
			 * last packet in the buffer.
969
			 *
970
			 * We treat ep < bp as an indication that this
971
			 * happened, and just set p->cc to 0.
972
			 */
973
			if (p->cc < 0)
974
				p->cc = 0;
958
			if (n == 0) {
975
			if (n == 0) {
959
				p->break_loop = 0;
976
				p->break_loop = 0;
960
				return (PCAP_ERROR_BREAK);
977
				return (PCAP_ERROR_BREAK);
961
			} else {
978
			} else
962
				p->bp = bp;
963
				p->cc = ep - bp;
964
				return (n);
979
				return (n);
965
			}
966
		}
980
		}
967
981
968
		caplen = bhp->bh_caplen;
982
		caplen = bhp->bh_caplen;
Lines 1014-1019 pcap_read_bpf(pcap_t *p, int cnt, pcap_handler callback, u_char *user) Link Here
1014
			if (++n >= cnt && cnt > 0) {
1028
			if (++n >= cnt && cnt > 0) {
1015
				p->bp = bp;
1029
				p->bp = bp;
1016
				p->cc = ep - bp;
1030
				p->cc = ep - bp;
1031
				/*
1032
				 * See comment above about p->cc < 0.
1033
				 */
1034
				if (p->cc < 0)
1035
					p->cc = 0;
1017
				return (n);
1036
				return (n);
1018
			}
1037
			}
1019
		} else {
1038
		} else {

Return to bug 150176