From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/5075 Path: news.gmane.org!not-for-mail From: Christian Wiese Newsgroups: gmane.linux.lib.musl.general Subject: [PATCH] fix sysconf(_SC_LINE_MAX) to return LINE_MAX Date: Wed, 7 May 2014 11:26:39 +0200 Message-ID: <20140507112639.219b38f3@mopad> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; boundary="Sig_/z1wi18BAMC1exz1I8J8OxMO"; protocol="application/pgp-signature" X-Trace: ger.gmane.org 1399454961 11402 80.91.229.3 (7 May 2014 09:29:21 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 7 May 2014 09:29:21 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: musl-return-5081-gllmg-musl=m.gmane.org@lists.openwall.com Wed May 07 11:29:15 2014 Return-path: Envelope-to: gllmg-musl@plane.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by plane.gmane.org with smtp (Exim 4.69) (envelope-from ) id 1WhyA5-0007j0-Sz for gllmg-musl@plane.gmane.org; Wed, 07 May 2014 11:29:13 +0200 Original-Received: (qmail 13336 invoked by uid 550); 7 May 2014 09:29:13 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: Original-Received: (qmail 13328 invoked from network); 7 May 2014 09:29:12 -0000 X-Mailer: Claws Mail 3.9.3 (GTK+ 2.24.23; i686-pc-linux-gnu) Xref: news.gmane.org gmane.linux.lib.musl.general:5075 Archived-At: --Sig_/z1wi18BAMC1exz1I8J8OxMO Content-Type: multipart/mixed; boundary="MP_/m2xcR2e0nESlpmf1vY.kAPR" --MP_/m2xcR2e0nESlpmf1vY.kAPR Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Content-Disposition: inline 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 --=20 PGP Fingerprint: F96B A15F DF25 2B3E 49CB BA16 241B F3E7 52FE AFC6 --MP_/m2xcR2e0nESlpmf1vY.kAPR Content-Type: text/x-patch Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename=musl-fix-sysconf-_SC_LINE_MAX-to-return-LINE_MAX.patch =46rom 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 =3D sysconf(_SC_LINE_MAX); lbuf =3D 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] =3D COLL_WEIGHTS_MAX, [_SC_EQUIV_CLASS_MAX] =3D -1, /* ?? */ [_SC_EXPR_NEST_MAX] =3D -1, - [_SC_LINE_MAX] =3D -1, + [_SC_LINE_MAX] =3D LINE_MAX, [_SC_RE_DUP_MAX] =3D RE_DUP_MAX, [_SC_CHARCLASS_NAME_MAX] =3D -1, /* ?? */ [_SC_2_VERSION] =3D VER, --=20 1.9.1 --MP_/m2xcR2e0nESlpmf1vY.kAPR-- --Sig_/z1wi18BAMC1exz1I8J8OxMO Content-Type: application/pgp-signature; name=signature.asc Content-Disposition: attachment; filename=signature.asc -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iEYEARECAAYFAlNp/E8ACgkQJBvz51L+r8Y2iQCgy0JBI87HmVav8/JwAbKeUp5z lpYAoNy1vH+dq6/tTN73EBo8VTX8Hhgj =SWMC -----END PGP SIGNATURE----- --Sig_/z1wi18BAMC1exz1I8J8OxMO--