From 0c4e55bbaa21f24f66e57a555341924840850c71 Mon Sep 17 00:00:00 2001 From: Andre Noll Date: Wed, 26 Nov 2008 00:33:55 +0100 Subject: [PATCH] para_write: Fix --bufsize. The given value means kilobytes, rather than bytes. Add checks for invalid values of the buffer size. --- write.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/write.c b/write.c index 50ed2212..998a6d2c 100644 --- 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; -- 2.39.5