From 9f7717649e338e53e8d068e8722f03229d1dd99b Mon Sep 17 00:00:00 2001 From: Christian Wiese Date: Wed, 7 May 2014 10:43:28 +0200 Subject: [PATCH] fix sysconf(_SC_LINE_MAX) to return LINE_MAX The problem was discovered when calling the wall(1) command from util-linux --------------------------------------------------------------------------- ./wall "123" wall: cannot allocate 18446744073709551615 bytes: Out of memory --------------------------------------------------------------------------- triggered by 'makemsg()' in 'term-utils/wall.c' which uses sysconf() to determine LINE_MAX for allocating a buffer through the builtin xmalloc() ---------------%<---------------------------------------------------------- char *p, *lbuf, *tmpname, *mbuf; long line_max; line_max = sysconf(_SC_LINE_MAX); lbuf = xmalloc(line_max); ---------------%<---------------------------------------------------------- which fails because in musl sysconf(_SC_LINE_MAX) is always returning -1. Signed-off-by: Christian Wiese --- src/conf/sysconf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/conf/sysconf.c b/src/conf/sysconf.c index bf433d6..21e0743 100644 --- a/src/conf/sysconf.c +++ b/src/conf/sysconf.c @@ -66,7 +66,7 @@ long sysconf(int name) [_SC_COLL_WEIGHTS_MAX] = COLL_WEIGHTS_MAX, [_SC_EQUIV_CLASS_MAX] = -1, /* ?? */ [_SC_EXPR_NEST_MAX] = -1, - [_SC_LINE_MAX] = -1, + [_SC_LINE_MAX] = LINE_MAX, [_SC_RE_DUP_MAX] = RE_DUP_MAX, [_SC_CHARCLASS_NAME_MAX] = -1, /* ?? */ [_SC_2_VERSION] = VER, -- 1.9.1