Martin Natano
2016-01-20 09:02:04 UTC
Below the conversion to uiomove() for isofs/udf/. Note that converting
size to size_t is not possible in udf_read(), as udf_readatoffset()
requires a pointer to an integer variable. Changing that would cause a
lot of code churn, so i chose to truncate uio_resid to INT_MAX instead.
udf_readatoffset() wouldn't transfer more than MAXBSIZE bytes anyway.
Index: udf_vnops.c
===================================================================
RCS file: /cvs/src/sys/isofs/udf/udf_vnops.c,v
retrieving revision 1.61
diff -u -p -u -r1.61 udf_vnops.c
--- udf_vnops.c 23 Sep 2015 15:37:26 -0000 1.61
+++ udf_vnops.c 20 Jan 2016 08:54:21 -0000
@@ -445,13 +445,12 @@ udf_read(void *v)
while (uio->uio_offset < fsize && uio->uio_resid > 0) {
offset = uio->uio_offset;
- if (uio->uio_resid + offset <= fsize)
- size = uio->uio_resid;
- else
+ size = ulmin(uio->uio_resid, INT_MAX);
+ if (size > fsize - offset)
size = fsize - offset;
error = udf_readatoffset(up, &size, offset, &bp, &data);
if (error == 0)
- error = uiomovei(data, size, uio);
+ error = uiomove(data, (size_t)size, uio);
if (bp != NULL) {
brelse(bp);
bp = NULL;
@@ -543,7 +542,7 @@ struct udf_uiodir {
static int
udf_uiodir(struct udf_uiodir *uiodir, struct uio *uio, long off)
{
- int de_size = DIRENT_SIZE(uiodir->dirent);
+ size_t de_size = DIRENT_SIZE(uiodir->dirent);
if (uio->uio_resid < de_size) {
uiodir->eofflag = 0;
@@ -552,7 +551,7 @@ udf_uiodir(struct udf_uiodir *uiodir, st
uiodir->dirent->d_off = off;
uiodir->dirent->d_reclen = de_size;
- return (uiomovei(uiodir->dirent, de_size, uio));
+ return (uiomove(uiodir->dirent, de_size, uio));
}
static struct udf_dirstream *
cheers,
natano
size to size_t is not possible in udf_read(), as udf_readatoffset()
requires a pointer to an integer variable. Changing that would cause a
lot of code churn, so i chose to truncate uio_resid to INT_MAX instead.
udf_readatoffset() wouldn't transfer more than MAXBSIZE bytes anyway.
Index: udf_vnops.c
===================================================================
RCS file: /cvs/src/sys/isofs/udf/udf_vnops.c,v
retrieving revision 1.61
diff -u -p -u -r1.61 udf_vnops.c
--- udf_vnops.c 23 Sep 2015 15:37:26 -0000 1.61
+++ udf_vnops.c 20 Jan 2016 08:54:21 -0000
@@ -445,13 +445,12 @@ udf_read(void *v)
while (uio->uio_offset < fsize && uio->uio_resid > 0) {
offset = uio->uio_offset;
- if (uio->uio_resid + offset <= fsize)
- size = uio->uio_resid;
- else
+ size = ulmin(uio->uio_resid, INT_MAX);
+ if (size > fsize - offset)
size = fsize - offset;
error = udf_readatoffset(up, &size, offset, &bp, &data);
if (error == 0)
- error = uiomovei(data, size, uio);
+ error = uiomove(data, (size_t)size, uio);
if (bp != NULL) {
brelse(bp);
bp = NULL;
@@ -543,7 +542,7 @@ struct udf_uiodir {
static int
udf_uiodir(struct udf_uiodir *uiodir, struct uio *uio, long off)
{
- int de_size = DIRENT_SIZE(uiodir->dirent);
+ size_t de_size = DIRENT_SIZE(uiodir->dirent);
if (uio->uio_resid < de_size) {
uiodir->eofflag = 0;
@@ -552,7 +551,7 @@ udf_uiodir(struct udf_uiodir *uiodir, st
uiodir->dirent->d_off = off;
uiodir->dirent->d_reclen = de_size;
- return (uiomovei(uiodir->dirent, de_size, uio));
+ return (uiomove(uiodir->dirent, de_size, uio));
}
static struct udf_dirstream *
cheers,
natano