]> git.ipfire.org Git - thirdparty/shadow.git/commitdiff
lib/chkname.c: An object cannot expand further than the universe in which it resides
authorAlejandro Colomar <alx@kernel.org>
Sat, 13 Jul 2024 09:37:25 +0000 (11:37 +0200)
committerIker Pedrosa <ikerpedrosam@gmail.com>
Mon, 15 Jul 2024 13:01:11 +0000 (15:01 +0200)
If you want a larger object, you'll have to wait at least until the
universe expands so much.

If an implementation doesn't recognize its own limitations, its a bug,
not a feature.

Closes: <https://github.com/shadow-maint/shadow/issues/1052>
Cc: Tobias Stoeckmann <tobias@stoeckmann.org>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
lib/chkname.c

index 995562fa1412c507cf2883e37183c95d3245d90c..bc631f2e1be1cefb2ffd1c65cdae33b1e716ad5c 100644 (file)
@@ -24,6 +24,8 @@
 #include <limits.h>
 #include <stdbool.h>
 #include <stddef.h>
+#include <stdint.h>
+#include <sys/param.h>
 #include <unistd.h>
 
 #include "defines.h"
@@ -43,7 +45,7 @@ login_name_max_size(void)
        if (conf == -1 && errno != 0)
                return LOGIN_NAME_MAX;
 
-       return conf;
+       return MIN(conf, PTRDIFF_MAX);
 }