diff options
author | Benny Baumann <BenBE@geshi.org> | 2024-03-10 16:18:29 +0100 |
---|---|---|
committer | cgzones <cgzones@googlemail.com> | 2024-03-27 20:06:42 +0100 |
commit | 3eb8bfa4cc1712621a18aaf12bef6420a19e55c0 (patch) | |
tree | 7bc2dcdeb072f69a43d4124488c98f90304db337 /linux | |
parent | cdf7a5a93be45c7c72bfdcbc5795a68cd8536c18 (diff) |
Avoid glibc FILE API for secattr
Diffstat (limited to 'linux')
-rw-r--r-- | linux/LinuxProcessTable.c | 14 |
1 files changed, 4 insertions, 10 deletions
diff --git a/linux/LinuxProcessTable.c b/linux/LinuxProcessTable.c index 2285667d..428199d2 100644 --- a/linux/LinuxProcessTable.c +++ b/linux/LinuxProcessTable.c @@ -971,21 +971,15 @@ static void LinuxProcessTable_readAutogroup(LinuxProcess* process, openat_arg_t } static void LinuxProcessTable_readSecattrData(LinuxProcess* process, openat_arg_t procFd) { - FILE* file = fopenat(procFd, "attr/current", "r"); - if (!file) { - free(process->secattr); - process->secattr = NULL; - return; - } + char buffer[PROC_LINE_LENGTH + 1] = {0}; - char buffer[PROC_LINE_LENGTH + 1]; - const char* res = fgets(buffer, sizeof(buffer), file); - fclose(file); - if (!res) { + ssize_t attrdata = xReadfileat(procFd, "attr/current", buffer, sizeof(buffer)); + if (attrdata < 1) { free(process->secattr); process->secattr = NULL; return; } + char* newline = strchr(buffer, '\n'); if (newline) { *newline = '\0'; |