Skip to content

Commit

Permalink
lib/tcbfuncs.c: shadowtcb_path_rel(): Centralize error handling
Browse files Browse the repository at this point in the history
All these 3 branches have a compatible return value, which we can check
at once after the branches.

Signed-off-by: Alejandro Colomar <[email protected]>
  • Loading branch information
alejandro-colomar committed Jan 10, 2025
1 parent 9ee3c41 commit 6028771
Showing 1 changed file with 4 additions and 12 deletions.
16 changes: 4 additions & 12 deletions lib/tcbfuncs.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,25 +73,17 @@ static /*@null@*/ char *shadowtcb_path_rel (const char *name, uid_t uid)

if (!getdef_bool ("TCB_SYMLINKS") || uid < SHADOWTCB_HASH_BY) {
ret = strdup(name);
if (ret == NULL) {
OUT_OF_MEMORY;
return NULL;
}
} else if (uid < SHADOWTCB_HASH_BY * SHADOWTCB_HASH_BY) {
ret = aprintf(":%dK/%s", uid / SHADOWTCB_HASH_BY, name);
if (ret == NULL) {
OUT_OF_MEMORY;
return NULL;
}
} else {
ret = aprintf(":%dM/:%dK/%s",
uid / (SHADOWTCB_HASH_BY * SHADOWTCB_HASH_BY),
(uid % (SHADOWTCB_HASH_BY * SHADOWTCB_HASH_BY)) / SHADOWTCB_HASH_BY,
name);
if (ret == NULL) {
OUT_OF_MEMORY;
return NULL;
}
}
if (ret == NULL) {
OUT_OF_MEMORY;
return NULL;
}
return ret;
}
Expand Down

0 comments on commit 6028771

Please sign in to comment.