Date: Wed, 30 Jan 2013 08:21:10 +0200 From: Kimmo Paasiala <kpaasial@gmail.com> To: James <james@hicag.org> Cc: Dimitry Andric <dim@freebsd.org>, Brooks Davis <brooks@freebsd.org>, FreeBSD Stable Mailing List <freebsd-stable@freebsd.org> Subject: Re: CLANG 3.2 breaks security/pam_ssh_agent_auth on stable/9 Message-ID: <CA%2B7WWScAqRa2Yurpgg5bH5FB=vQ6vYXGtz56qadcV9RgAcP=SQ@mail.gmail.com> In-Reply-To: <CAD4099nFbzRyFSeQ4NN7J7ts0fXijsOf%2BjrCXn7WrauyWPJcrw@mail.gmail.com> References: <CA%2B7WWSeOpuAv9PL2_G6Z1Q_SLv5xcTjcujiw6Rs8tdBsrLO7wQ@mail.gmail.com> <50F6D20A.6070306@FreeBSD.org> <CA%2B7WWSfE1bAr7GriRGAKBVpkiNE%2Btn-%2Bd0cO3vpNPY-SWxfghg@mail.gmail.com> <20130117001116.GD29437@lor.one-eyed-alien.net> <CA%2B7WWSdW95=qBthPKWtn1uT_FTD2ka-oQXLo-owFEn=kO4GYRg@mail.gmail.com> <50F81588.5020106@FreeBSD.org> <CA%2B7WWSfrpvJXAqrn8d=j1yXZmUw_itxtxJyxYExPnE-JNE2%2Bpw@mail.gmail.com> <51081E18.60303@sentex.net> <CA%2B7WWSfvit0G_LL57e6dU%2BZRWnrgip_pwGUqtSudfu_UPqzkmQ@mail.gmail.com> <CAD4099nFbzRyFSeQ4NN7J7ts0fXijsOf%2BjrCXn7WrauyWPJcrw@mail.gmail.com>
next in thread | previous in thread | raw e-mail | index | archive | help
[-- Attachment #1 --]
On Wed, Jan 30, 2013 at 7:27 AM, James <james@hicag.org> wrote:
> I was able to correct the problem as well by prefixing strnvis, avoiding the
> symbol collision. I also found PR: ports/172941 which also has a fix.
>
> Using my patch or the patch in ports/172941 fixes the segfault for me in
> stable/9. However, I quickly ran into another problem. I can't remember the
> error message exactly, it was something like "Unable to initialize PAM:
> Unknown file descriptor". A ktrace didn't reveal anything obvious. I'll try
> to test it out tomorrow.
>
> --
> James.
Try the attached patch. Just drop it into
/usr/ports/security/pam_ssh_agent_auth/files directory and recompile.
This will make the port use the system strnvis() with correctly
ordered arguments if one is available (HAVE_STRNVIS defined) and an
_openbsd suffixed version if not.
-Kimmo
[-- Attachment #2 --]
--- ../../../pam_ssh_agent_auth/work/pam_ssh_agent_auth-0.9.3/openbsd-compat/vis.h 2009-01-05 09:31:07.000000000 +0200
+++ openbsd-compat/vis.h 2013-01-30 07:13:19.782431257 +0200
@@ -79,15 +79,16 @@
*/
#define UNVIS_END 1 /* no more characters */
-char *vis(char *, int, int, int);
-int strvis(char *, const char *, int);
-int strnvis(char *, const char *, size_t, int)
+
+char *vis_openbsd(char *, int, int, int);
+int strvis_openbsd(char *, const char *, int);
+int strnvis_openbsd(char *, const char *, size_t, int)
__attribute__ ((__bounded__(__string__,1,3)));
-int strvisx(char *, const char *, size_t, int)
+int strvisx_openbsd(char *, const char *, size_t, int)
__attribute__ ((__bounded__(__string__,1,3)));
-int strunvis(char *, const char *);
-int unvis(char *, char, int *, int);
-ssize_t strnunvis(char *, const char *, size_t)
+int strunvis_openbsd(char *, const char *);
+int unvis_openbsd(char *, char, int *, int);
+ssize_t strnunvis_openbsd(char *, const char *, size_t)
__attribute__ ((__bounded__(__string__,1,3)));
#endif /* !_VIS_H_ */
--- ../../../pam_ssh_agent_auth/work/pam_ssh_agent_auth-0.9.3/log.c 2013-01-30 07:09:24.325405879 +0200
+++ log.c 2013-01-30 07:14:13.708422511 +0200
@@ -360,9 +360,13 @@
snprintf(fmtbuf, sizeof(fmtbuf), "%s: %s", preface, fmt);
vsnprintf(msgbuf, sizeof(msgbuf), fmtbuf, args);
}
-
- strnvis(fmtbuf, msgbuf, sizeof(fmtbuf),
+#if defined (HAVE_STRNVIS)
+ strnvis(fmtbuf, sizeof(fmtbuf), msgbuf,
+ log_on_stderr ? LOG_STDERR_VIS : LOG_SYSLOG_VIS);
+#else
+ strnvis_openbsd(fmtbuf, msgbuf, sizeof(fmtbuf),
log_on_stderr ? LOG_STDERR_VIS : LOG_SYSLOG_VIS);
+#endif
if(level == SYSLOG_LEVEL_FATAL) {
snprintf(msgbuf, sizeof msgbuf, "%s\r\nThis incident has been reported to the authorities\r\n", fmtbuf);
--- ../../../pam_ssh_agent_auth/work/pam_ssh_agent_auth-0.9.3/openbsd-compat/vis.c 2009-01-05 09:31:07.000000000 +0200
+++ openbsd-compat/vis.c 2013-01-30 07:31:50.516441571 +0200
@@ -54,7 +54,7 @@
* vis - visually encode characters
*/
char *
-vis(char *dst, int c, int flag, int nextc)
+vis_openbsd(char *dst, int c, int flag, int nextc)
{
if (isvisible(c)) {
*dst++ = c;
@@ -151,19 +151,19 @@
* This is useful for encoding a block of data.
*/
int
-strvis(char *dst, const char *src, int flag)
+strvis_openbsd(char *dst, const char *src, int flag)
{
char c;
char *start;
for (start = dst; (c = *src);)
- dst = vis(dst, c, flag, *++src);
+ dst = vis_openbsd(dst, c, flag, *++src);
*dst = '\0';
return (dst - start);
}
int
-strnvis(char *dst, const char *src, size_t siz, int flag)
+strnvis_openbsd(char *dst, const char *src, size_t siz, int flag)
{
char *start, *end;
char tbuf[5];
@@ -186,7 +186,7 @@
}
src++;
} else {
- i = vis(tbuf, c, flag, *++src) - tbuf;
+ i = vis_openbsd(tbuf, c, flag, *++src) - tbuf;
if (dst + i <= end) {
memcpy(dst, tbuf, i);
dst += i;
@@ -201,23 +201,23 @@
if (dst + i > end) {
/* adjust return value for truncation */
while ((c = *src))
- dst += vis(tbuf, c, flag, *++src) - tbuf;
+ dst += vis_openbsd(tbuf, c, flag, *++src) - tbuf;
}
return (dst - start);
}
int
-strvisx(char *dst, const char *src, size_t len, int flag)
+strvisx_openbsd(char *dst, const char *src, size_t len, int flag)
{
char c;
char *start;
for (start = dst; len > 1; len--) {
c = *src;
- dst = vis(dst, c, flag, *++src);
+ dst = vis_openbsd(dst, c, flag, *++src);
}
if (len)
- dst = vis(dst, *src, flag, '\0');
+ dst = vis_openbsd(dst, *src, flag, '\0');
*dst = '\0';
return (dst - start);
}
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CA%2B7WWScAqRa2Yurpgg5bH5FB=vQ6vYXGtz56qadcV9RgAcP=SQ>
