Fix based on Coverity and Sonar audits (part 5) (#22333)
sqlite: fix decimal mode literal on recovery marker file Sonar c:S2612: mark_database_to_recover() created the .netdata-meta.db.recover / .delete marker with `open(..., O_WRONLY | O_CREAT | O_TRUNC | O_CLOEXEC, 444)`. The literal `444` is decimal, which is octal 0o674 (rw-rwxr--) -- group rwx + others r. Same decimal-not-octal typo as the previous api_v1_manage.c commit. The file is a marker created and immediately closed (no body written); only its existence matters at next-startup recovery detection. It does not need group or other access. Use mode 0600 -- minimum permissions needed by the owning netdata process, eliminates the c:S2612 violation. Co-authored-by: Costa Tsaousis <costa@netdata.cloud>
Stelios Fragkakis committed
May 1, 2026 at 11:15 UTC
ed6e8ebf8f8bee5e8b9445238e15f031fb7694c5
1 file changed
+1
-1
src/database/sqlite/sqlite_functions.c
+1
-1
@@ -77,7 +77,7 @@ static bool mark_database_to_recover(sqlite3_stmt *res, sqlite3 *database, int r
77
if (db_meta == database) {
78
char recover_file[FILENAME_MAX + 1];
79
snprintfz(recover_file, FILENAME_MAX, "%s/.netdata-meta.db.%s", netdata_configured_cache_dir, SQLITE_CORRUPT == rc ? "recover" : "delete" );
80
- int fd = open(recover_file, O_WRONLY | O_CREAT | O_TRUNC | O_CLOEXEC, 444);
80
+ int fd = open(recover_file, O_WRONLY | O_CREAT | O_TRUNC | O_CLOEXEC, 0600);
81
if (fd >= 0) {
82
close(fd);
83
return true;