The chmod() result is completely discarded, while chown() is stored in a variable that is immediately cast to void. This means permission/ownership restoration failures are silently ignored, and there is no way for the caller to know that metadata restoration failed.
Location
src/shared/metadata.c:99-101
Suggested Fix
Check the return values and log warnings on failure:
if(chmod(path,metadata->mode&07777)!=0)log_message(LOG_LEVEL_WARNING,"Failed to restore permissions on %s",path);if(chown(path,metadata->uid,metadata->gid)!=0)log_message(LOG_LEVEL_WARNING,"Failed to restore ownership on %s (may be expected if not root)",path);
Severity
Low
Category
Quality
## Description
In `src/shared/metadata.c` lines 99-101, the return values of `chmod()` and `chown()` are ignored:
```c
chmod(path, metadata->mode & 07777);
int chown_ret = chown(path, metadata->uid, metadata->gid);
(void)chown_ret;
```
The `chmod()` result is completely discarded, while `chown()` is stored in a variable that is immediately cast to void. This means permission/ownership restoration failures are silently ignored, and there is no way for the caller to know that metadata restoration failed.
## Location
`src/shared/metadata.c:99-101`
## Suggested Fix
Check the return values and log warnings on failure:
```c
if (chmod(path, metadata->mode & 07777) != 0)
log_message(LOG_LEVEL_WARNING, "Failed to restore permissions on %s", path);
if (chown(path, metadata->uid, metadata->gid) != 0)
log_message(LOG_LEVEL_WARNING, "Failed to restore ownership on %s (may be expected if not root)", path);
```
## Severity
Low
## Category
Quality
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Description
In
src/shared/metadata.clines 99-101, the return values ofchmod()andchown()are ignored:The
chmod()result is completely discarded, whilechown()is stored in a variable that is immediately cast to void. This means permission/ownership restoration failures are silently ignored, and there is no way for the caller to know that metadata restoration failed.Location
src/shared/metadata.c:99-101Suggested Fix
Check the return values and log warnings on failure:
Severity
Low
Category
Quality