瀏覽代碼

qcacmn: Fix compilation error observed with LTS 6.6.17

Below errors are observed with LTS 6.6.17:

htc_recv.c:49:4: error: 'snprintf' will always be truncated; specified \
size is 2, but format string expands to at least 5
[-Werror,-Wfortify-source].

htc_recv.c:58:3: error: 'snprintf' will always be truncated; specified \
size is 2, but format string expands to at least 5
[-Werror,-Wfortify-source].

Here, the compilation error is because the 2nd argument to snprintf is
using sizeof(byteOffset) which evaluates to 2 and the size of the buffer
we are writing to is 10 and when the format string content expands to
atleast 5 characters, only 2 characters are written to the output string.

Fix is to use size of the buffer we are writing to as the
snprintf 2nd argument.

CRs-Fixed: 3763920
Change-Id: I156260d26df643cd68b2e5d7fb7bf5d95f8026b2
Srinivas Girigowda 1 年之前
父節點
當前提交
d303c5209c
共有 1 個文件被更改,包括 3 次插入3 次删除
  1. 3 3
      htc/htc_recv.c

+ 3 - 3
htc/htc_recv.c

@@ -1,6 +1,6 @@
 /*
  * Copyright (c) 2013-2021 The Linux Foundation. All rights reserved.
- * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved.
+ * Copyright (c) 2023-2024 Qualcomm Innovation Center, Inc. All rights reserved.
  *
  * Permission to use, copy, modify, and/or distribute this software for
  * any purpose with or without fee is hereby granted, provided that the
@@ -46,7 +46,7 @@ void debug_dump_bytes(uint8_t *buffer, uint16_t length, char *pDescription)
 		if (count == 16) {
 			count = 0;
 			offset = 0;
-			A_SNPRINTF(byteOffsetStr, sizeof(byteOffset), "%4.4X",
+			A_SNPRINTF(byteOffsetStr, sizeof(byteOffsetStr), "%4.4X",
 				   byteOffset);
 			A_PRINTF("[%s]: %s\n", byteOffsetStr, stream);
 			qdf_mem_zero(stream, 60);
@@ -55,7 +55,7 @@ void debug_dump_bytes(uint8_t *buffer, uint16_t length, char *pDescription)
 	}
 
 	if (offset != 0) {
-		A_SNPRINTF(byteOffsetStr, sizeof(byteOffset), "%4.4X",
+		A_SNPRINTF(byteOffsetStr, sizeof(byteOffsetStr), "%4.4X",
 			   byteOffset);
 		A_PRINTF("[%s]: %s\n", byteOffsetStr, stream);
 	}