mirror of
https://gitlab.alpinelinux.org/alpine/aports.git
synced 2025-07-23 03:05:48 +03:00
25 lines
926 B
Diff
25 lines
926 B
Diff
From 8ca2bcc67e7fd74ac2bc663857ba36f515a9d5e3 Mon Sep 17 00:00:00 2001
|
|
From: =?UTF-8?q?Dan=20Hor=C3=A1k?= <dan@danny.cz>
|
|
Date: Fri, 18 Jun 2021 18:29:25 +0200
|
|
Subject: [PATCH] use a safe way to copy the chip string
|
|
|
|
based on https://developers.redhat.com/blog/2019/08/12/efficient-string-copying-and-concatenation-in-c
|
|
|
|
Fixes: https://github.com/rockchip-linux/rkdeveloptool/issues/55
|
|
---
|
|
main.cpp | 2 +-
|
|
1 file changed, 1 insertion(+), 1 deletion(-)
|
|
|
|
diff --git a/main.cpp b/main.cpp
|
|
index 72bd94b..c14ed97 100644
|
|
--- a/main.cpp
|
|
+++ b/main.cpp
|
|
@@ -1490,7 +1490,7 @@ static bool saveEntry(FILE* outFile, char* path, rk_entry_type type,
|
|
static inline uint32_t convertChipType(const char* chip) {
|
|
char buffer[5];
|
|
memset(buffer, 0, sizeof(buffer));
|
|
- snprintf(buffer, sizeof(buffer), "%s", chip);
|
|
+ memccpy(buffer, chip, '\0', sizeof(buffer));
|
|
return buffer[0] << 24 | buffer[1] << 16 | buffer[2] << 8 | buffer[3];
|
|
}
|
|
|