ryantimwilson / rpms / systemd

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