From 317f1f95694cc29b3615a80f016a4b6f29e46ec3 Mon Sep 17 00:00:00 2001
From: Steve Lhomme <robux4@ycbcr.xyz>
Date: Fri, 2 Sep 2022 06:40:39 +0200
Subject: [PATCH] modules: optimize string maximum size checks

No need to go through all the chars when we can test the the maximum size we
want to reach before deciding it's too much with strnlen().
---
 modules/misc/audioscrobbler.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/modules/misc/audioscrobbler.c b/modules/misc/audioscrobbler.c
index 1fbee6a7690f..c4175045f1d2 100644
--- a/modules/misc/audioscrobbler.c
+++ b/modules/misc/audioscrobbler.c
@@ -590,7 +590,7 @@ static int Handshake(intf_thread_t *p_this)
         goto proto;
 
     p_buffer_pos = strstr(p_buffer_pos, "\n");
-    if (!p_buffer_pos || strlen(p_buffer_pos) < 33)
+    if (!p_buffer_pos || strnlen(p_buffer_pos, 33) < 33)
         goto proto;
     p_buffer_pos++; /* we skip the '\n' */
 
-- 
GitLab