0001-server.c-fix-build-failure-as-static-library.patch 1.3 KB

12345678910111213141516171819202122232425262728293031323334
  1. From 74b228c74c7821dbe16d7730040030eed2f01a28 Mon Sep 17 00:00:00 2001
  2. From: Giulio Benetti <giulio.benetti@benettiengineering.com>
  3. Date: Mon, 7 Jul 2025 22:58:10 +0200
  4. Subject: [PATCH] server.c: fix build failure as static library
  5. As static library strncpy() can't determine precise maximum characters
  6. because strlen() is variable, so to fix build failure let's convert 3
  7. lines into one by using strdup() that does the same as the actual code.
  8. Upstream: https://sourceforge.net/p/liblo/patches/9/
  9. Signed-off-by: Giulio Benetti <giulio.benetti@benettiengineering.com>
  10. ---
  11. src/server.c | 5 +----
  12. 1 file changed, 1 insertion(+), 4 deletions(-)
  13. diff --git a/src/server.c b/src/server.c
  14. index 130f6d5..1236279 100644
  15. --- a/src/server.c
  16. +++ b/src/server.c
  17. @@ -2062,10 +2062,7 @@ static void dispatch_method(lo_server s, const char *path,
  18. char *tmp;
  19. char *sec;
  20. - int tmplen = (int) strlen(it->path + len) + 1;
  21. - tmp = (char*) malloc(strlen(it->path + len) + 1);
  22. - strncpy(tmp, it->path + len, tmplen);
  23. - tmp[tmplen-1]=0;
  24. + tmp = strdup(it->path + len);
  25. sec = strchr(tmp, '/');
  26. if (sec)
  27. *sec = '\0';
  28. --
  29. 2.39.5