4.4BSD snapshot (revision 8.1); add 1993 to copyright
[unix-history] / usr / src / usr.bin / cmp / regular.c
index c3aa116..d06628a 100644 (file)
@@ -1,17 +1,19 @@
 /*-
 /*-
- * Copyright (c) 1991 The Regents of the University of California.
- * All rights reserved.
+ * Copyright (c) 1991, 1993
+ *     The Regents of the University of California.  All rights reserved.
  *
  * %sccs.include.redist.c%
  */
 
 #ifndef lint
  *
  * %sccs.include.redist.c%
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)regular.c  5.3 (Berkeley) %G%";
+static char sccsid[] = "@(#)regular.c  8.1 (Berkeley) %G%";
 #endif /* not lint */
 
 #include <sys/param.h>
 #include <sys/mman.h>
 #include <sys/stat.h>
 #endif /* not lint */
 
 #include <sys/param.h>
 #include <sys/mman.h>
 #include <sys/stat.h>
+
+#include <limits.h>
 #include <errno.h>
 #include <stdlib.h>
 #include <stdio.h>
 #include <errno.h>
 #include <stdlib.h>
 #include <stdio.h>
@@ -39,11 +41,14 @@ c_regular(fd1, file1, skip1, len1, fd2, file2, skip2, len2)
        len2 -= skip2;
 
        length = MIN(len1, len2);
        len2 -= skip2;
 
        length = MIN(len1, len2);
+       if (length > SIZE_T_MAX)
+               return (c_special(fd1, file1, skip1, fd2, file2, skip2));
+
        if ((p1 = (u_char *)mmap(NULL,
        if ((p1 = (u_char *)mmap(NULL,
-           (int)length, PROT_READ, MAP_FILE, fd1, skip1)) == (u_char *)-1)
+           (size_t)length, PROT_READ, 0, fd1, skip1)) == (u_char *)-1)
                err("%s: %s", file1, strerror(errno));
        if ((p2 = (u_char *)mmap(NULL,
                err("%s: %s", file1, strerror(errno));
        if ((p2 = (u_char *)mmap(NULL,
-           (int)length, PROT_READ, MAP_FILE, fd2, skip2)) == (u_char *)-1)
+           (size_t)length, PROT_READ, 0, fd2, skip2)) == (u_char *)-1)
                err("%s: %s", file2, strerror(errno));
 
        dfound = 0;
                err("%s: %s", file2, strerror(errno));
 
        dfound = 0;