FreeBSD Bugzilla – Attachment 211760 Details for
Bug 244226
[patch] syslogd converts all 8-bit chars to M-x sequences
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
patch to add locale support to syslogd when converting strings to "safe" sequences
syslogd.c.diff (text/plain), 1.69 KB, created by
J.R. Oldroyd
on 2020-02-19 11:50:20 UTC
(
hide
)
Description:
patch to add locale support to syslogd when converting strings to "safe" sequences
Filename:
MIME Type:
Creator:
J.R. Oldroyd
Created:
2020-02-19 11:50:20 UTC
Size:
1.69 KB
patch
obsolete
>--- usr.sbin/syslogd/syslogd.c.orig 2019-11-23 01:36:17.347873000 +0100 >+++ usr.sbin/syslogd/syslogd.c 2020-02-19 12:28:07.503105000 +0100 >@@ -133,6 +133,7 @@ > #include <fnmatch.h> > #include <libutil.h> > #include <limits.h> >+#include <locale.h> > #include <netdb.h> > #include <paths.h> > #include <signal.h> >@@ -141,8 +142,11 @@ > #include <stdlib.h> > #include <string.h> > #include <sysexits.h> >+#include <uchar.h> > #include <unistd.h> > #include <utmpx.h> >+#include <vis.h> >+#include <wctype.h> > > #include "pathnames.h" > #include "ttymsg.h" >@@ -734,6 +738,9 @@ > /* tuck my process id away */ > pidfile_write(pfh); > >+ /* set the character set locale */ >+ setlocale(LC_CTYPE, getenv("LC_CTYPE")); >+ > dprintf("off & running....\n"); > > tvp = &tv; >@@ -911,28 +918,33 @@ > static void > parsemsg_remove_unsafe_characters(const char *in, char *out, size_t outlen) > { >+ const char *p; > char *q; > int c; >+ size_t n; > >+ p = in; > q = out; >- while ((c = (unsigned char)*in++) != '\0' && q < out + outlen - 4) { >- if (mask_C1 && (c & 0x80) && c < 0xA0) { >- c &= 0x7F; >- *q++ = 'M'; >- *q++ = '-'; >+ while (*p != '\0' && q < out + outlen - 1) { >+ n = mbrtoc32(&c, p, (size_t)4, NULL); >+ if (n == 0) >+ break; >+ if (n < 0 || n > (size_t)4) { >+ /* invalid char sequence for this charset */ >+ c = *p; >+ n = (size_t)1; > } >- if (isascii(c) && iscntrl(c)) { >- if (c == '\n') { >- *q++ = ' '; >- } else if (c == '\t') { >- *q++ = '\t'; >- } else { >- *q++ = '^'; >- *q++ = c ^ 0100; >- } >+ if (c == '\n') { >+ *q++ = ' '; >+ } else if (c == '\t') { >+ *q++ = '\t'; >+ } else if (iswgraph(c)) { >+ strncpy(q, p, n); >+ q += n; > } else { >- *q++ = c; >+ q = vis(q, c, 0, 0); > } >+ p += n; > } > *q = '\0'; > }
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 244226
:
211760
|
211894