From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/8427 Path: news.gmane.org!not-for-mail From: Isaac Dunham Newsgroups: gmane.linux.lib.musl.general Subject: Re: [PATCH] Implement glibc *_chk interfaces for ABI compatibility. Date: Sun, 30 Aug 2015 18:10:12 -0700 Message-ID: <20150831011011.GA2232@newbook> References: <1434509291-28997-1-git-send-email-josiahw@gmail.com> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="EeQfGwPcQSOJBaQU" X-Trace: ger.gmane.org 1440983430 25406 80.91.229.3 (31 Aug 2015 01:10:30 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 31 Aug 2015 01:10:30 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: musl-return-8439-gllmg-musl=m.gmane.org@lists.openwall.com Mon Aug 31 03:10:29 2015 Return-path: Envelope-to: gllmg-musl@m.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by plane.gmane.org with smtp (Exim 4.69) (envelope-from ) id 1ZWDcD-0001uy-Km for gllmg-musl@m.gmane.org; Mon, 31 Aug 2015 03:10:29 +0200 Original-Received: (qmail 29700 invoked by uid 550); 31 Aug 2015 01:10:28 -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 28655 invoked from network); 31 Aug 2015 01:10:27 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:subject:message-id:references:mime-version :content-type:content-disposition:in-reply-to:user-agent; bh=T80VuUUO4YnPkvRo3Y9z/R5ETrJ17/fI69lJBdK8aGo=; b=Bl3V1FVreE7HhcpeZEarGji9kuDcW4NFbLBR5J7a0KoTW4XCGG/9cWmStvuOmFOOS0 dKGjYMNbCeNILUGSiJBy+XKTiToj214sZwGd9r/YY/gr/f8PBGXereceuR5tQ5389gDE u9ImRZUSmJNJGARWp+ihYjIPYYpWVbNPC7rG31+Sdo5yh5J7qKXsc7F8r3WkIbnCdZWE mXHxV7jfakoQ0uTjU0DnvkXcWPxGGT5MQE3kSn7JeVcNfQyt6rVbchDSk95fS8DNyM74 wMiY8TvIeY723enKyEhgypHqAYnZ00QXZsbLL8Dt8BCc2ipIMNSlp5imgVDHQC42Uc8f MRYA== X-Received: by 10.66.230.201 with SMTP id ta9mr33290148pac.95.1440983415532; Sun, 30 Aug 2015 18:10:15 -0700 (PDT) Content-Disposition: inline In-Reply-To: <1434509291-28997-1-git-send-email-josiahw@gmail.com> User-Agent: Mutt/1.5.23 (2014-03-12) Xref: news.gmane.org gmane.linux.lib.musl.general:8427 Archived-At: --EeQfGwPcQSOJBaQU Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Not a fix for the issues discussed, but some compile issues and one missing function. I did this in the process of making the ksh93 binary from Debian run on Alpine (there are a few other functions I've done rather hackish stubs for, mostly math stuff; but that's another matter.) Thanks, Isaac --EeQfGwPcQSOJBaQU Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="0001-src-compat-_chk.c-fix-build-add-__strcpy_chk.patch" >From 3a9fdda5680fed183f0b33a9412fb88e0cb8f6a8 Mon Sep 17 00:00:00 2001 From: Isaac Dunham Date: Tue, 30 Jun 2015 21:06:20 -0700 Subject: [PATCH] src/compat/*_chk.c: fix build, add __strcpy_chk() --- src/compat/longjmp_chk.c | 4 ++-- src/compat/posix_chk.c | 7 +------ src/compat/realpath_chk.c | 2 +- src/compat/string_chk.c | 6 ++++++ src/compat/ttyname_r_chk.c | 1 + src/compat/wchar_chk.c | 2 +- 6 files changed, 12 insertions(+), 10 deletions(-) diff --git a/src/compat/longjmp_chk.c b/src/compat/longjmp_chk.c index e814ecc..576a1b5 100644 --- a/src/compat/longjmp_chk.c +++ b/src/compat/longjmp_chk.c @@ -1,7 +1,7 @@ #include #include -_Noreturn void __longjmp_chk(sigjmp_buf buf, int ret) +_Noreturn void __longjmp_chk(jmp_buf buf, int ret) { - longjmp((jmp_buf)buf, ret); + longjmp(buf, ret); } diff --git a/src/compat/posix_chk.c b/src/compat/posix_chk.c index 7e39754..2b9a845 100644 --- a/src/compat/posix_chk.c +++ b/src/compat/posix_chk.c @@ -1,3 +1,4 @@ +#include #include #include #include @@ -93,12 +94,6 @@ long __fdelt_chk(long d) return d / (8 * sizeof(d)); } -int __ttyname_r_chk(int fd, char *name, size_t size, size_t namelen) -{ - if (size > namelen) a_crash(); - return ttyname_r(fd, name, size); -} - char *__stpcpy_chk(char *d, const char *s, size_t dlen) { size_t slen = strnlen(s, dlen) + 1; diff --git a/src/compat/realpath_chk.c b/src/compat/realpath_chk.c index cc0089e..c2ac9f8 100644 --- a/src/compat/realpath_chk.c +++ b/src/compat/realpath_chk.c @@ -1,6 +1,6 @@ #include #include -#include "atomics.h" +#include "atomic.h" char *__realpath_chk(const char *filename, char *resolved, size_t resolved_len) { diff --git a/src/compat/string_chk.c b/src/compat/string_chk.c index ba77c9c..8a17c48 100644 --- a/src/compat/string_chk.c +++ b/src/compat/string_chk.c @@ -40,6 +40,12 @@ char *__strncat_chk(char *restrict dest, const char *restrict src, size_t n, siz return strncat(dest, src, n); } +char *__strcpy_chk(char *restrict dest, const char *restrict src, size_t destlen) +{ + if ( strlen(src) >= destlen) a_crash(); + return strcpy(dest, src); +} + char *__strncpy_chk(char *restrict dest, const char *restrict src, size_t n, size_t destlen) { if (n > destlen) a_crash(); diff --git a/src/compat/ttyname_r_chk.c b/src/compat/ttyname_r_chk.c index 50e70e5..cbede51 100644 --- a/src/compat/ttyname_r_chk.c +++ b/src/compat/ttyname_r_chk.c @@ -1,4 +1,5 @@ #include +#include "atomic.h" int __ttyname_r_chk(int fd, char *name, size_t size, size_t namelen) { diff --git a/src/compat/wchar_chk.c b/src/compat/wchar_chk.c index 66e35b1..fd5b075 100644 --- a/src/compat/wchar_chk.c +++ b/src/compat/wchar_chk.c @@ -5,7 +5,7 @@ size_t __mbsnrtowcs_chk(wchar_t *restrict wcs, const char **restrict src, size_t n, size_t wn, mbstate_t *restrict st, size_t wcslen) { if (wn > wcslen) a_crash(); - return msbnrtowcs(wcs, src, n, wn, st); + return mbsnrtowcs(wcs, src, n, wn, st); } size_t __mbsrtowcs_chk(wchar_t *restrict ws, const char **restrict src, size_t wn, mbstate_t *restrict st, size_t wslen) -- 2.5.0 --EeQfGwPcQSOJBaQU--