From 1991ae94590bf6b6fc0a9f8afd4bb6cdac22668f Mon Sep 17 00:00:00 2001 From: Ting-Yuan Huang Date: Tue, 29 Aug 2017 15:48:30 -0700 Subject: [PATCH] sdcard: mute false compiler alarm Clang static analyzer worries that strcpy to a field may overwrites other fields. Use snprintf() instead. Test: built without seeing the warning. Change-Id: I75d8edf1353b5d052fd14a954362bd0632c258fa --- sdcard/sdcard.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sdcard/sdcard.cpp b/sdcard/sdcard.cpp index df3ce853c..f1e4a7bc4 100644 --- a/sdcard/sdcard.cpp +++ b/sdcard/sdcard.cpp @@ -249,7 +249,9 @@ static void run(const char* source_path, const char* label, uid_t uid, global.root.uid = AID_ROOT; global.root.under_android = false; - strcpy(global.source_path, source_path); + // Clang static analyzer think strcpy potentially overwrites other fields + // in global. Use snprintf() to mute the false warning. + snprintf(global.source_path, sizeof(global.source_path), "%s", source_path); if (multi_user) { global.root.perm = PERM_PRE_ROOT;