Skip to content

Commit c2ca033

Browse files
lib/sub.c: subsystem(): Prevent -Wstrict-overflow diagnostic
The compiler thinks ++depth within the conditional could overflow the type, because it doesn't see that exit(3) will terminate the program. Let's make it easy for the compiler, and only increment the value if we're not going to call exit(3). Signed-off-by: Alejandro Colomar <[email protected]>
1 parent 4a34a60 commit c2ca033

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

lib/sub.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,13 @@ void subsystem (const struct passwd *pw)
3434
/*
3535
* Prevent endless loop on misconfigured systems.
3636
*/
37-
if (++depth > MAX_DEPTH) {
37+
if (depth >= MAX_DEPTH) {
3838
printf (_("Maximum subsystem depth reached\n"));
3939
SYSLOG ((LOG_WARN, MAX_SUBROOT2));
4040
closelog ();
4141
exit (EXIT_FAILURE);
4242
}
43+
depth++;
4344

4445
/*
4546
* The new root directory must begin with a "/" character.

0 commit comments

Comments
 (0)