diff --git a/bin/cat/cat.c b/bin/cat/cat.c index 4632b88f56c..b69adbdcd7f 100644 --- a/bin/cat/cat.c +++ b/bin/cat/cat.c @@ -300,6 +300,7 @@ ilseq: static void raw_cat(int rfd) { + long pagesize; int off, wfd; ssize_t nr, nw; static size_t bsize; @@ -316,9 +317,12 @@ raw_cat(int rfd) bsize = MIN(BUFSIZE_MAX, MAXPHYS * 8); else bsize = BUFSIZE_SMALL; - } else - bsize = MAX(sbuf.st_blksize, - (blksize_t)sysconf(_SC_PAGESIZE)); + } else { + bsize = sbuf.st_blksize; + pagesize = sysconf(_SC_PAGESIZE); + if (pagesize > 0) + bsize = MAX(bsize, (size_t)pagesize); + } if ((buf = malloc(bsize)) == NULL) err(1, "malloc() failure of IO buffer"); }