File: utsn.patch

package info (click to toggle)
libs3 2.0-5
  • links: PTS
  • area: main
  • in suites: forky, sid, trixie
  • size: 872 kB
  • sloc: ansic: 6,950; xml: 227; sh: 109; makefile: 12
file content (32 lines) | stat: -rw-r--r-- 1,160 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
Description: use system utsn lengths
 Calculate platform length based on system constants.
Author: Laszlo Boszormenyi (GCS) <gcs@debian.org>
Author: Mattias Ellert <mattias.ellert@physics.uu.se>
Bug-Debian: https://bugs.debian.org/853509
Bug-Debian: https://bugs.debian.org/1104235
Bug: https://github.com/bji/libs3/pull/116
Last-Update: 2025-05-04

diff -ur libs3-2.0.orig/src/request.c libs3-2.0/src/request.c
--- libs3-2.0.orig/src/request.c	2011-09-28 10:16:09.000000000 +0200
+++ libs3-2.0/src/request.c	2025-05-04 17:55:25.000000000 +0200
@@ -35,7 +35,8 @@
 #include "util.h"
 
 
-#define USER_AGENT_SIZE 256
+#define USER_AGENT_SIZE 126 + sizeof(((struct utsname*)0)->sysname) \
+                            + sizeof(((struct utsname*)0)->machine)
 #define REQUEST_STACK_SIZE 32
 
 static char userAgentG[USER_AGENT_SIZE];
@@ -1089,8 +1090,8 @@
         userAgentInfo = "Unknown";
     }
 
-    char platform[96];
     struct utsname utsn;
+    char platform[sizeof(utsn.sysname) + 1 + sizeof(utsn.machine) + 1];
     if (uname(&utsn)) {
         strncpy(platform, "Unknown", sizeof(platform));
         // Because strncpy doesn't always zero terminate