PERFORCE change 113783 for review

Christian S.J. Peron csjp at FreeBSD.org
Wed Jan 31 19:04:32 UTC 2007


http://perforce.freebsd.org/chv.cgi?CH=113783

Change 113783 by csjp at csjp_rnd01 on 2007/01/31 19:04:17

	use malloc buffer instead of stack allocated storage

Affected files ...

.. //depot/projects/zcopybpf/utils/bpfnull/bpfnull.c#4 edit

Differences ...

==== //depot/projects/zcopybpf/utils/bpfnull/bpfnull.c#4 (text+ko) ====

@@ -83,9 +83,12 @@
 {
 	fd_set s_set, r_set;
 	struct bpf_zbuf bz;
-	char pbuf[65535];
+	char *pbuf;
 	int n;
 
+	pbuf = malloc(bflag + 1);
+	if (pbuf == NULL)
+		err(1, "malloc");
 	FD_SET(fd, &s_set);
         for (;;) {
 		r_set = s_set;
@@ -98,10 +101,10 @@
 			(void) fprintf(stderr,
 			    "DEBUG: wokeup and bpf is ready to read from\n");
 		if (zflag == 0) {
-			n = read(fd, &pbuf[0], bflag);
+			n = read(fd, pbuf, bflag);
 			if (n < 0)
 				err(1, "read failed");
-			bz.bz_bufa = &pbuf[0];
+			bz.bz_bufa = pbuf;
 			bz.bz_buflen = n;
 		} else
 			if (ioctl(fd, BIOCGETZNEXT, &bz) < 0)


More information about the p4-projects mailing list