mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Isaac Dunham <ibid.ag@gmail.com>
To: musl@lists.openwall.com
Subject: Re: [PATCH] Implement glibc *_chk interfaces for ABI compatibility.
Date: Sun, 30 Aug 2015 18:10:12 -0700	[thread overview]
Message-ID: <20150831011011.GA2232@newbook> (raw)
In-Reply-To: <1434509291-28997-1-git-send-email-josiahw@gmail.com>

[-- Attachment #1: Type: text/plain, Size: 297 bytes --]

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


[-- Attachment #2: 0001-src-compat-_chk.c-fix-build-add-__strcpy_chk.patch --]
[-- Type: text/plain, Size: 3232 bytes --]

From 3a9fdda5680fed183f0b33a9412fb88e0cb8f6a8 Mon Sep 17 00:00:00 2001
From: Isaac Dunham <ibid.ag@gmail.com>
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 <setjmp.h>
 #include <signal.h>
 
-_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 <sys/select.h>
 #include <poll.h>
 #include <sys/socket.h>
 #include <unistd.h>
@@ -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 <stdlib.h>
 #include <limits.h>
-#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 <unistd.h>
+#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


      parent reply	other threads:[~2015-08-31  1:10 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-17  2:48 Josiah Worcester
2015-06-17  9:30 ` Szabolcs Nagy
2015-06-17 19:07   ` Josiah Worcester
2015-06-18  0:40     ` Rich Felker
2015-06-20 20:32 ` Rich Felker
2015-08-30 23:14 ` Rich Felker
2015-08-31  1:10 ` Isaac Dunham [this message]

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=20150831011011.GA2232@newbook \
    --to=ibid.ag@gmail.com \
    --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).