teknoraver / rpms / systemd

Forked from rpms/systemd 3 months ago
Clone

Blame SOURCES/0400-sd-bus-avoid-magic-number-in-SASL-length-calculation.patch

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