]> git.tue.mpg.de Git - paraslash.git/commitdiff
para_write: Fix --bufsize.
authorAndre Noll <maan@systemlinux.org>
Tue, 25 Nov 2008 23:33:55 +0000 (00:33 +0100)
committerAndre Noll <maan@systemlinux.org>
Tue, 25 Nov 2008 23:33:55 +0000 (00:33 +0100)
The given value means kilobytes, rather than bytes. Add checks
for invalid values of the buffer size.

write.c

diff --git a/write.c b/write.c
index 50ed2212f111a106e46793ec46e9e19725713046..998a6d2cccde01cf45bcb6e5dea9d5e11c3f7da0 100644 (file)
--- a/write.c
+++ b/write.c
@@ -200,8 +200,12 @@ int main(int argc, char *argv[])
        if (!wng)
                goto out;
        stdin_set_defaults(&sit);
-       if (conf.bufsize_given)
-               sit.bufsize = conf.bufsize_arg;
+       ret = -ERRNO_TO_PARA_ERROR(EINVAL);
+       if (conf.bufsize_arg < 0)
+               goto out;
+       if (conf.bufsize_arg >= INT_MAX / 1024)
+               goto out;
+       sit.bufsize = conf.bufsize_arg * 1024;
        sit.buf = para_malloc(sit.bufsize);
 
        wng->buf = sit.buf;