naccyde / rpms / systemd

Forked from rpms/systemd a year ago
Clone
52b84b
From d524f9f9089b71d83e991ed42d25a4616ec575a2 Mon Sep 17 00:00:00 2001
52b84b
From: David Rheinsberg <david.rheinsberg@gmail.com>
52b84b
Date: Thu, 14 Mar 2019 13:26:50 +0100
52b84b
Subject: [PATCH] sd-bus: avoid magic number in SASL length calculation
52b84b
52b84b
Lets avoid magic numbers and use a constant `strlen()` instead.
52b84b
52b84b
Signed-off-by: David Rheinsberg <david.rheinsberg@gmail.com>
52b84b
(cherry picked from commit 3cacdab925c40a5d9b7cf3f67719201bbaa17f67)
52b84b
52b84b
Related: #1838081
52b84b
---
52b84b
 src/libsystemd/sd-bus/bus-socket.c | 8 ++++++--
52b84b
 1 file changed, 6 insertions(+), 2 deletions(-)
52b84b
52b84b
diff --git a/src/libsystemd/sd-bus/bus-socket.c b/src/libsystemd/sd-bus/bus-socket.c
52b84b
index 4a72795d2b..1c8b331b48 100644
52b84b
--- a/src/libsystemd/sd-bus/bus-socket.c
52b84b
+++ b/src/libsystemd/sd-bus/bus-socket.c
52b84b
@@ -390,7 +390,9 @@ static int bus_socket_auth_verify_server(sd_bus *b) {
52b84b
 
52b84b
                 if (line_begins(line, l, "AUTH ANONYMOUS")) {
52b84b
 
52b84b
-                        r = verify_anonymous_token(b, line + 14, l - 14);
52b84b
+                        r = verify_anonymous_token(b,
52b84b
+                                                   line + strlen("AUTH ANONYMOUS"),
52b84b
+                                                   l - strlen("AUTH ANONYMOUS"));
52b84b
                         if (r < 0)
52b84b
                                 return r;
52b84b
                         if (r == 0)
52b84b
@@ -402,7 +404,9 @@ static int bus_socket_auth_verify_server(sd_bus *b) {
52b84b
 
52b84b
                 } else if (line_begins(line, l, "AUTH EXTERNAL")) {
52b84b
 
52b84b
-                        r = verify_external_token(b, line + 13, l - 13);
52b84b
+                        r = verify_external_token(b,
52b84b
+                                                  line + strlen("AUTH EXTERNAL"),
52b84b
+                                                  l - strlen("AUTH EXTERNAL"));
52b84b
                         if (r < 0)
52b84b
                                 return r;
52b84b
                         if (r == 0)