]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
util: virprocess: Use local maximum error message size
authorPeter Krempa <pkrempa@redhat.com>
Tue, 23 Feb 2021 14:21:13 +0000 (15:21 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Fri, 5 Mar 2021 14:01:29 +0000 (15:01 +0100)
Use of VIR_ERROR_MAX_LENGTH is actually misleading to the readers
because it implies that the strings in virError are 1024 bytes at most.

That isn't true at least for the 'message' field as it's constructed
from concatenating the detail string which (was) max 1024 bytes with
the string variant of the error code without limiting to 1024.

Use a local copy for declaring the struct for error transport with a
comment so that's obvious that it's a local decision to use 1k buffers.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
src/util/virprocess.c

index 7a0960e337b469b2cd54a0562335ff816009d4e4..80cf4e883893477956217b5150af80c1d640e879 100644 (file)
@@ -1137,14 +1137,16 @@ virProcessRunInMountNamespace(pid_t pid G_GNUC_UNUSED,
 
 
 #ifndef WIN32
+/* We assume that error messages will fit into 1024 chars */
+# define VIR_PROCESS_ERROR_MAX_LENGTH 1024
 typedef struct {
     int code;
     int domain;
-    char message[VIR_ERROR_MAX_LENGTH];
+    char message[VIR_PROCESS_ERROR_MAX_LENGTH];
     virErrorLevel level;
-    char str1[VIR_ERROR_MAX_LENGTH];
-    char str2[VIR_ERROR_MAX_LENGTH];
-    char str3[VIR_ERROR_MAX_LENGTH];
+    char str1[VIR_PROCESS_ERROR_MAX_LENGTH];
+    char str2[VIR_PROCESS_ERROR_MAX_LENGTH];
+    char str3[VIR_PROCESS_ERROR_MAX_LENGTH];
     int int1;
     int int2;
 } errorData;