Do multiply in lseek calls as off_t arithmetic. This allows for seeks
of more than INT_MAX. Removed Check for INT_MAX as maximum seeks. Fixes PR 2101.
This commit is contained in:
parent
0a3628b2c3
commit
d355fd58e8
@ -1,4 +1,4 @@
|
|||||||
/* $NetBSD: args.c,v 1.8 1997/07/20 21:58:36 christos Exp $ */
|
/* $NetBSD: args.c,v 1.9 1997/07/25 06:46:23 phil Exp $ */
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c) 1991, 1993, 1994
|
* Copyright (c) 1991, 1993, 1994
|
||||||
@ -42,7 +42,7 @@
|
|||||||
#if 0
|
#if 0
|
||||||
static char sccsid[] = "@(#)args.c 8.3 (Berkeley) 4/2/94";
|
static char sccsid[] = "@(#)args.c 8.3 (Berkeley) 4/2/94";
|
||||||
#else
|
#else
|
||||||
__RCSID("$NetBSD: args.c,v 1.8 1997/07/20 21:58:36 christos Exp $");
|
__RCSID("$NetBSD: args.c,v 1.9 1997/07/25 06:46:23 phil Exp $");
|
||||||
#endif
|
#endif
|
||||||
#endif /* not lint */
|
#endif /* not lint */
|
||||||
|
|
||||||
@ -169,14 +169,19 @@ jcl(argv)
|
|||||||
errx(1, "buffer sizes cannot be zero");
|
errx(1, "buffer sizes cannot be zero");
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Read, write and seek calls take ints as arguments. Seek sizes
|
* Check to make sure that the buffers are not too large.
|
||||||
* could be larger if we wanted to do it in stages or check only
|
|
||||||
* regular files, but it's probably not worth it.
|
|
||||||
*/
|
*/
|
||||||
if (in.dbsz > INT_MAX || out.dbsz > INT_MAX)
|
if (in.dbsz > INT_MAX || out.dbsz > INT_MAX)
|
||||||
errx(1, "buffer sizes cannot be greater than %d", INT_MAX);
|
errx(1, "buffer sizes cannot be greater than %d", INT_MAX);
|
||||||
if (in.offset > INT_MAX / in.dbsz || out.offset > INT_MAX / out.dbsz)
|
|
||||||
errx(1, "seek offsets cannot be larger than %d", INT_MAX);
|
/* Read, write and seek calls take off_t as arguments.
|
||||||
|
*
|
||||||
|
* The following check is not done because an off_t is a quad
|
||||||
|
* for current NetBSD implementations.
|
||||||
|
*
|
||||||
|
* if (in.offset > INT_MAX/in.dbsz || out.offset > INT_MAX/out.dbsz)
|
||||||
|
* errx(1, "seek offsets cannot be larger than %d", INT_MAX);
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $NetBSD: position.c,v 1.5 1997/07/20 21:58:41 christos Exp $ */
|
/* $NetBSD: position.c,v 1.6 1997/07/25 06:46:24 phil Exp $ */
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c) 1991, 1993, 1994
|
* Copyright (c) 1991, 1993, 1994
|
||||||
@ -42,7 +42,7 @@
|
|||||||
#if 0
|
#if 0
|
||||||
static char sccsid[] = "@(#)position.c 8.3 (Berkeley) 4/2/94";
|
static char sccsid[] = "@(#)position.c 8.3 (Berkeley) 4/2/94";
|
||||||
#else
|
#else
|
||||||
__RCSID("$NetBSD: position.c,v 1.5 1997/07/20 21:58:41 christos Exp $");
|
__RCSID("$NetBSD: position.c,v 1.6 1997/07/25 06:46:24 phil Exp $");
|
||||||
#endif
|
#endif
|
||||||
#endif /* not lint */
|
#endif /* not lint */
|
||||||
|
|
||||||
@ -72,7 +72,8 @@ pos_in()
|
|||||||
|
|
||||||
/* If not a character, pipe or tape device, try to seek on it. */
|
/* If not a character, pipe or tape device, try to seek on it. */
|
||||||
if (!(in.flags & (ISCHR|ISPIPE|ISTAPE))) {
|
if (!(in.flags & (ISCHR|ISPIPE|ISTAPE))) {
|
||||||
if (lseek(in.fd, (off_t)(in.offset * in.dbsz), SEEK_CUR) == -1)
|
if (lseek(in.fd, (off_t)in.offset * (off_t)in.dbsz, SEEK_CUR)
|
||||||
|
== -1)
|
||||||
err(1, "%s", in.name);
|
err(1, "%s", in.name);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -132,7 +133,7 @@ pos_out()
|
|||||||
*/
|
*/
|
||||||
if (!(out.flags & ISTAPE)) {
|
if (!(out.flags & ISTAPE)) {
|
||||||
if (lseek(out.fd,
|
if (lseek(out.fd,
|
||||||
(off_t)out.offset * out.dbsz, SEEK_SET) == -1)
|
(off_t)out.offset * (off_t)out.dbsz, SEEK_SET) == -1)
|
||||||
err(1, "%s", out.name);
|
err(1, "%s", out.name);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user