the maximum int; set bt_rfp to NULL if not set, used as a flag in close
SCCS-vsn: lib/libc/db/recno/rec_open.c 5.3
*/
#if defined(LIBC_SCCS) && !defined(lint)
*/
#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)rec_open.c 5.2 (Berkeley) %G%";
+static char sccsid[] = "@(#)rec_open.c 5.3 (Berkeley) %G%";
#endif /* LIBC_SCCS and not lint */
#include <sys/types.h>
#endif /* LIBC_SCCS and not lint */
#include <sys/types.h>
t->bt_bval = '\n';
t->bt_flags = BTF_RECNO;
t->bt_bval = '\n';
t->bt_flags = BTF_RECNO;
- * In 4.4BSD stat(2) returns true for ISSOCK on pipes. Until then,
- * this is fairly close. Pipes are read-only.
- */
+ * In 4.4BSD stat(2) returns true for ISSOCK on pipes. Until
+ * then, this is fairly close. Pipes are read-only.
+ */
if (lseek(rfd, 0L, SEEK_CUR) == -1 && errno == ESPIPE) {
SET(t, BTF_RDONLY);
if ((t->bt_rfp = fdopen(rfd, "r")) == NULL)
if (lseek(rfd, 0L, SEEK_CUR) == -1 && errno == ESPIPE) {
SET(t, BTF_RDONLY);
if ((t->bt_rfp = fdopen(rfd, "r")) == NULL)
goto err;
if (!(flags & (O_RDWR | O_WRONLY)))
SET(t, BTF_RDONLY);
goto err;
if (!(flags & (O_RDWR | O_WRONLY)))
SET(t, BTF_RDONLY);
- if ((t->bt_smap = mmap(NULL, sb.st_size, PROT_READ, MAP_FILE,
- rfd, (off_t)0)) == NULL)
+ if (sb.st_size > INT_MAX) {
+ errno = EFBIG;
+ goto err;
+ }
+ if ((t->bt_smap = mmap(NULL, (int)sb.st_size,
+ PROT_READ, MAP_FILE, rfd, (off_t)0)) == NULL)
goto err;
t->bt_emap = t->bt_smap + sb.st_size;
t->bt_rfd = rfd;
goto err;
t->bt_emap = t->bt_smap + sb.st_size;
t->bt_rfd = rfd;
t->bt_irec = ISSET(t, BTF_FIXEDLEN) ? __rec_fmap : __rec_vmap;
}
t->bt_irec = ISSET(t, BTF_FIXEDLEN) ? __rec_fmap : __rec_vmap;
}