File ppc64-diag.bug-1072708_increase_buffer_for_vpd.patch of Package ppc64-diag.10030

commit 1837ee17e201c66ed13ae1665a08a92fc42cb347
Author: Ankit Kumar <ankit@linux.vnet.ibm.com>
Date:   Tue Dec 5 14:56:12 2017 +0530

    diags: Increase buffer length size to read complete system vpd information
    
    System vpd information(system id, model) can have prefix substring
    as IBM and hence our buffer must handle those extra string to get
    correct serial number and model information.
    This patch increased buffer length to 16 bytes(8-serial/model number + 8 - to
    capture other substring).
    
    Signed-off-by: Ankit Kumar <ankit@linux.vnet.ibm.com>
    Signed-off-by: Vasant Hegde <hegdevasant@linux.vnet.ibm.com>

Index: ppc64-diag-2.7.4/diags/diag_disk.c
===================================================================
--- ppc64-diag-2.7.4.orig/diags/diag_disk.c
+++ ppc64-diag-2.7.4/diags/diag_disk.c
@@ -44,6 +44,7 @@
 #define DEVICE_TREE_SYSTEM_ID		DEVICE_TREE"system-id"
 #define DEVICE_TREE_MODEL		DEVICE_TREE"model"
 
+#define BUFFER_LENGTH			16
 #define SERIAL_NUM_LEN			8
 #define MACHINE_MODEL_LEN		8
 
@@ -196,15 +197,15 @@ static int get_system_vpd(char *machine_
 	int device_fd;
 	int rc;
 	int start_index = 0;
-	char serial[SERIAL_NUM_LEN + 1] = {0};
-	char model[MACHINE_MODEL_LEN + 1] = {0};
+	char serial[BUFFER_LENGTH] = {0};
+	char model[BUFFER_LENGTH] = {0};
 	char *temp;
 
 	device_fd = open(DEVICE_TREE_SYSTEM_ID, O_RDONLY);
 	if (device_fd < 0)
 		return -1;
 
-	rc = read(device_fd, serial, SERIAL_NUM_LEN);
+	rc = read(device_fd, serial, BUFFER_LENGTH);
 	close(device_fd);
 	if (rc <= 0)
 		return -1;
@@ -218,7 +219,7 @@ static int get_system_vpd(char *machine_
 	if (device_fd < 0)
 		return -1;
 
-	rc = read(device_fd, model, MACHINE_MODEL_LEN);
+	rc = read(device_fd, model, BUFFER_LENGTH);
 	close(device_fd);
 	if (rc <= 0)
 		return -1;
openSUSE Build Service is sponsored by