chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
socket: add option for SO_PASSCRED
[elogind.git]
/
src
/
stdout-syslog-bridge.c
diff --git
a/src/stdout-syslog-bridge.c
b/src/stdout-syslog-bridge.c
index 48a301f6a711ffd2fb8d8213b4868abfed8fd70a..9a0408819ec964a1626cadcd2090268065c8323f 100644
(file)
--- a/
src/stdout-syslog-bridge.c
+++ b/
src/stdout-syslog-bridge.c
@@
-88,7
+88,7
@@
struct Stream {
bool prefix:1;
bool tee_console:1;
bool prefix:1;
bool tee_console:1;
- char buffer[LINE_MAX];
+ char buffer[LINE_MAX
+1
];
size_t length;
LIST_FIELDS(Stream, stream);
size_t length;
LIST_FIELDS(Stream, stream);
@@
-111,9
+111,9
@@
static int stream_log(Stream *s, char *p, usec_t ts) {
if (*p == 0)
return 0;
if (*p == 0)
return 0;
- /* Patch in
LOG_USER
facility if necessary */
+ /* Patch in
configured
facility if necessary */
if ((priority & LOG_FACMASK) == 0)
if ((priority & LOG_FACMASK) == 0)
- priority =
LOG_USER | LOG_PRI(priority)
;
+ priority =
(s->priority & LOG_FACMASK) | priority
;
/*
* The format glibc uses to talk to the syslog daemon is:
/*
* The format glibc uses to talk to the syslog daemon is:
@@
-321,16
+321,25
@@
static int stream_scan(Stream *s, usec_t ts) {
p = s->buffer;
remaining = s->length;
for (;;) {
p = s->buffer;
remaining = s->length;
for (;;) {
- char *newline;
-
- if (!(newline = memchr(p, '\n', remaining)))
- break;
+ char *end;
+ size_t skip;
+
+ end = memchr(p, '\n', remaining);
+ if (!end) {
+ if (remaining >= LINE_MAX) {
+ end = p + LINE_MAX;
+ skip = LINE_MAX;
+ } else
+ break;
+ } else
+ skip = end - p + 1;
- *
newline
= 0;
+ *
end
= 0;
- if ((r = stream_line(s, p, ts)) >= 0) {
- remaining -= newline-p+1;
- p = newline+1;
+ r = stream_line(s, p, ts);
+ if (r >= 0) {
+ remaining -= skip;
+ p += skip;
}
}
}
}
@@
-347,7
+356,8
@@
static int stream_process(Stream *s, usec_t ts) {
int r;
assert(s);
int r;
assert(s);
- if ((l = read(s->fd, s->buffer+s->length, LINE_MAX-s->length)) < 0) {
+ l = read(s->fd, s->buffer+s->length, LINE_MAX-s->length);
+ if (l < 0) {
if (errno == EAGAIN)
return 0;
if (errno == EAGAIN)
return 0;