mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Christian Wiese <chris@opensde.net>
To: musl@lists.openwall.com
Subject: [PATCH] fix sysconf(_SC_LINE_MAX) to return LINE_MAX
Date: Wed, 7 May 2014 11:26:39 +0200	[thread overview]
Message-ID: <20140507112639.219b38f3@mopad> (raw)


[-- Attachment #1.1: Type: text/plain, Size: 218 bytes --]

Hi,

attached is a patch for fixing sysconf(_SC_LINE_MAX) to not always
return -1 but LINE_MAX as defined in limits.h.

Greetings
Chris

-- 
PGP Fingerprint: F96B A15F DF25 2B3E 49CB BA16 241B F3E7 52FE AFC6

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.2: musl-fix-sysconf-_SC_LINE_MAX-to-return-LINE_MAX.patch --]
[-- Type: text/x-patch, Size: 1636 bytes --]

From 9f7717649e338e53e8d068e8722f03229d1dd99b Mon Sep 17 00:00:00 2001
From: Christian Wiese <chris@opensde.org>
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 <chris@opensde.org>
---
 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


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 181 bytes --]

             reply	other threads:[~2014-05-07  9:26 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-07  9:26 Christian Wiese [this message]
2014-05-19 22:09 ` Rich Felker

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20140507112639.219b38f3@mopad \
    --to=chris@opensde.net \
    --cc=musl@lists.openwall.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).