para_write: Fix --bufsize.
[paraslash.git] / 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;