From b077c9f47d276ba32b187883958bb90a64dccdf4 Mon Sep 17 00:00:00 2001 From: Eric Andersen Date: Fri, 6 Dec 2002 21:39:48 +0000 Subject: [PATCH] Fixup buffer allocation --- coreutils/uuencode.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/coreutils/uuencode.c b/coreutils/uuencode.c index 1d42494fd..49b2d9189 100644 --- a/coreutils/uuencode.c +++ b/coreutils/uuencode.c @@ -83,19 +83,21 @@ static void uuencode (const char *s, const char *store, const int length, const *p = '\0'; } +#define SRC_BUF_SIZE 45 // This *MUST* be a multiple of 3 +#define DST_BUF_SIZE 4 * ((SRC_BUF_SIZE + 2) / 3) int uuencode_main(int argc, char **argv) { - const int src_buf_size = 45;// This *MUST* be a multiple of 3 - const int dst_buf_size = 4 * ((src_buf_size + 2) / 3); + const int src_buf_size = SRC_BUF_SIZE; + const int dst_buf_size = DST_BUF_SIZE; int write_size = dst_buf_size; - RESERVE_CONFIG_BUFFER(src_buf, src_buf_size + 1); - RESERVE_CONFIG_BUFFER(dst_buf, dst_buf_size + 1); struct stat stat_buf; FILE *src_stream = stdin; char *tbl = tbl_std; size_t size; mode_t mode; int opt; + RESERVE_CONFIG_BUFFER(src_buf, SRC_BUF_SIZE + 1); + RESERVE_CONFIG_BUFFER(dst_buf, DST_BUF_SIZE + 1); while ((opt = getopt(argc, argv, "m")) != -1) { switch (opt) { -- 2.25.1