On Wed, Jan 30, 2013 at 7:27 AM, James <ja...@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
--- 
../../../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);
 }
_______________________________________________
freebsd-stable@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-stable
To unsubscribe, send any mail to "freebsd-stable-unsubscr...@freebsd.org"

Reply via email to