Enable clang-tidy for security sensitive domain.
Start with clang-analyzer-security* and cert-*, but disable two
specific errors:
-- cert-err34-c, which checks for atoi(); heavily triggered by
CommandListener, but will disappear when we move to Binder.
-- cert-err58-cpp, which checks for exceptions before main(); it's
a "Low" severity issue, and filed 36656327 to track cleanup.
Fix all other triggered errors along the way.
Test: builds, boots
Bug: 36655947
Change-Id: I1391693fb521ed39700e25ab6b16bc741293bb79
diff --git a/VolumeManager.cpp b/VolumeManager.cpp
index 3b4c054..e038303 100644
--- a/VolumeManager.cpp
+++ b/VolumeManager.cpp
@@ -180,7 +180,7 @@
}
*createdDMDevice = true;
} else {
- strcpy(buffer, loopDevice);
+ strlcpy(buffer, loopDevice, len);
*createdDMDevice = false;
}
return 0;
@@ -931,7 +931,7 @@
cleanupDm = true;
} else {
sb.c_cipher = ASEC_SB_C_CIPHER_NONE;
- strcpy(dmDevice, loopDevice);
+ strlcpy(dmDevice, loopDevice, sizeof(dmDevice));
}
/*
@@ -1895,7 +1895,7 @@
// Create a string to compare against that has a trailing slash
int loopDirLen = strlen(VolumeManager::LOOPDIR);
char loopDir[loopDirLen + 2];
- strcpy(loopDir, VolumeManager::LOOPDIR);
+ strlcpy(loopDir, VolumeManager::LOOPDIR, sizeof(loopDir));
loopDir[loopDirLen++] = '/';
loopDir[loopDirLen] = '\0';