chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Add hasprefix macro to check prefixes of fixed length
[elogind.git]
/
src
/
journal
/
journald-native.c
diff --git
a/src/journal/journald-native.c
b/src/journal/journald-native.c
index 12fb980dd6c5312df7c8875332ae3d05f0003c69..ec9afa187de97be3fd9245219843cba637527b24 100644
(file)
--- a/
src/journal/journald-native.c
+++ b/
src/journal/journald-native.c
@@
-25,14
+25,16
@@
#include "socket-util.h"
#include "path-util.h"
#include "socket-util.h"
#include "path-util.h"
-#include "journald.h"
+#include "journald
-server
.h"
#include "journald-native.h"
#include "journald-kmsg.h"
#include "journald-console.h"
#include "journald-syslog.h"
#include "journald-native.h"
#include "journald-kmsg.h"
#include "journald-console.h"
#include "journald-syslog.h"
-#define ENTRY_SIZE_MAX (1024*1024*64)
-#define DATA_SIZE_MAX (1024*1024*64)
+/* Make sure not to make this smaller than the maximum coredump
+ * size. See COREDUMP_MAX in coredump.c */
+#define ENTRY_SIZE_MAX (1024*1024*768)
+#define DATA_SIZE_MAX (1024*1024*768)
static bool valid_user_field(const char *p, size_t l) {
const char *a;
static bool valid_user_field(const char *p, size_t l) {
const char *a;
@@
-121,11
+123,12
@@
void server_process_native_message(
/* A property follows */
/* A property follows */
- if (n+N_IOVEC_META_FIELDS >= m) {
+ /* n received properties, +1 for _TRANSPORT */
+ if (n + 1 + N_IOVEC_META_FIELDS >= m) {
struct iovec *c;
unsigned u;
struct iovec *c;
unsigned u;
- u = MAX((n
+N_IOVEC_META_FIELDS+1
) * 2U, 4U);
+ u = MAX((n
+ 1 + N_IOVEC_META_FIELDS
) * 2U, 4U);
c = realloc(iovec, u * sizeof(struct iovec));
if (!c) {
log_oom();
c = realloc(iovec, u * sizeof(struct iovec));
if (!c) {
log_oom();
@@
-155,23
+158,23
@@
void server_process_native_message(
* of this entry for the rate limiting
* logic */
if (l == 10 &&
* of this entry for the rate limiting
* logic */
if (l == 10 &&
-
memcmp(p, "PRIORITY=", 9) == 0
&&
+
hasprefix(p, "PRIORITY=")
&&
p[9] >= '0' && p[9] <= '9')
priority = (priority & LOG_FACMASK) | (p[9] - '0');
else if (l == 17 &&
p[9] >= '0' && p[9] <= '9')
priority = (priority & LOG_FACMASK) | (p[9] - '0');
else if (l == 17 &&
-
memcmp(p, "SYSLOG_FACILITY=", 16) == 0
&&
+
hasprefix(p, "SYSLOG_FACILITY=")
&&
p[16] >= '0' && p[16] <= '9')
priority = (priority & LOG_PRIMASK) | ((p[16] - '0') << 3);
else if (l == 18 &&
p[16] >= '0' && p[16] <= '9')
priority = (priority & LOG_PRIMASK) | ((p[16] - '0') << 3);
else if (l == 18 &&
-
memcmp(p, "SYSLOG_FACILITY=", 16) == 0
&&
+
hasprefix(p, "SYSLOG_FACILITY=")
&&
p[16] >= '0' && p[16] <= '9' &&
p[17] >= '0' && p[17] <= '9')
priority = (priority & LOG_PRIMASK) | (((p[16] - '0')*10 + (p[17] - '0')) << 3);
else if (l >= 19 &&
p[16] >= '0' && p[16] <= '9' &&
p[17] >= '0' && p[17] <= '9')
priority = (priority & LOG_PRIMASK) | (((p[16] - '0')*10 + (p[17] - '0')) << 3);
else if (l >= 19 &&
-
memcmp(p, "SYSLOG_IDENTIFIER=", 18) == 0
) {
+
hasprefix(p, "SYSLOG_IDENTIFIER=")
) {
char *t;
t = strndup(p + 18, l - 18);
char *t;
t = strndup(p + 18, l - 18);
@@
-180,7
+183,7
@@
void server_process_native_message(
identifier = t;
}
} else if (l >= 8 &&
identifier = t;
}
} else if (l >= 8 &&
-
memcmp(p, "MESSAGE=", 8) == 0
) {
+
hasprefix(p, "MESSAGE=")
) {
char *t;
t = strndup(p + 8, l - 8);
char *t;
t = strndup(p + 8, l - 8);
@@
-314,7
+317,7
@@
void server_process_native_file(
return;
}
return;
}
- if (
strchr(e, '/'
)) {
+ if (
!filename_is_safe(e
)) {
log_error("Received file in subdirectory of allowed directories. Refusing.");
return;
}
log_error("Received file in subdirectory of allowed directories. Refusing.");
return;
}
@@
-396,7
+399,7
@@
int server_open_native_socket(Server*s) {
#ifdef HAVE_SELINUX
one = 1;
#ifdef HAVE_SELINUX
one = 1;
- r = setsockopt(s->
syslog
_fd, SOL_SOCKET, SO_PASSSEC, &one, sizeof(one));
+ r = setsockopt(s->
native
_fd, SOL_SOCKET, SO_PASSSEC, &one, sizeof(one));
if (r < 0)
log_warning("SO_PASSSEC failed: %m");
#endif
if (r < 0)
log_warning("SO_PASSSEC failed: %m");
#endif