]> git.ipfire.org Git - thirdparty/systemd.git/blobdiff - src/journal/journald-native.c
util-lib: split our string related calls from util.[ch] into its own file string...
[thirdparty/systemd.git] / src / journal / journald-native.c
index f98269625542a96ba9ca2684e40a67978cea1d85..7a514b2848f0cdb7fef5fbd631ed0116ee42fe67 100644 (file)
   along with systemd; If not, see <http://www.gnu.org/licenses/>.
 ***/
 
-#include <unistd.h>
 #include <stddef.h>
 #include <sys/epoll.h>
 #include <sys/mman.h>
+#include <unistd.h>
 
-#include "socket-util.h"
-#include "path-util.h"
-#include "selinux-util.h"
-#include "journald-server.h"
-#include "journald-native.h"
-#include "journald-kmsg.h"
 #include "journald-console.h"
+#include "journald-kmsg.h"
+#include "journald-server.h"
 #include "journald-syslog.h"
 #include "journald-wall.h"
 #include "memfd-util.h"
+#include "path-util.h"
+#include "selinux-util.h"
+#include "socket-util.h"
+#include "string-util.h"
+#include "journald-native.h"
 
 bool valid_user_field(const char *p, size_t l, bool allow_protected) {
         const char *a;
@@ -134,8 +135,8 @@ void server_process_native_message(
 
                 /* A property follows */
 
-                /* n received properties, +1 for _TRANSPORT */
-                if (!GREEDY_REALLOC(iovec, m, n + 1 + N_IOVEC_META_FIELDS + !!object_pid * N_IOVEC_OBJECT_FIELDS)) {
+                /* n existing properties, 1 new, +1 for _TRANSPORT */
+                if (!GREEDY_REALLOC(iovec, m, n + 2 + N_IOVEC_META_FIELDS + N_IOVEC_OBJECT_FIELDS)) {
                         log_oom();
                         break;
                 }
@@ -184,6 +185,7 @@ void server_process_native_message(
                                                 free(identifier);
                                                 identifier = t;
                                         }
+
                                 } else if (l >= 8 &&
                                            startswith(p, "MESSAGE=")) {
                                         char *t;
@@ -193,6 +195,7 @@ void server_process_native_message(
                                                 free(message);
                                                 message = t;
                                         }
+
                                 } else if (l > strlen("OBJECT_PID=") &&
                                            l < strlen("OBJECT_PID=")  + DECIMAL_STR_MAX(pid_t) &&
                                            startswith(p, "OBJECT_PID=") &&
@@ -350,7 +353,7 @@ void server_process_native_file(
                         return;
                 }
 
-                if (!filename_is_safe(e)) {
+                if (!filename_is_valid(e)) {
                         log_error("Received file in subdirectory of allowed directories. Refusing.");
                         return;
                 }
@@ -433,7 +436,7 @@ int server_open_native_socket(Server*s) {
                 if (r < 0)
                         return log_error_errno(errno, "bind(%s) failed: %m", sa.un.sun_path);
 
-                chmod(sa.un.sun_path, 0666);
+                (void) chmod(sa.un.sun_path, 0666);
         } else
                 fd_nonblock(s->native_fd, 1);
 
@@ -453,7 +456,7 @@ int server_open_native_socket(Server*s) {
         if (r < 0)
                 return log_error_errno(errno, "SO_TIMESTAMP failed: %m");
 
-        r = sd_event_add_io(s->event, &s->native_event_source, s->native_fd, EPOLLIN, process_datagram, s);
+        r = sd_event_add_io(s->event, &s->native_event_source, s->native_fd, EPOLLIN, server_process_datagram, s);
         if (r < 0)
                 return log_error_errno(r, "Failed to add native server fd to event loop: %m");