diff options
Diffstat (limited to 'shadow/putspent.c')
-rw-r--r-- | shadow/putspent.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/shadow/putspent.c b/shadow/putspent.c index 142e697e64..fd57fec0af 100644 --- a/shadow/putspent.c +++ b/shadow/putspent.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991-2015 Free Software Foundation, Inc. +/* Copyright (C) 1991-2016 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -15,6 +15,8 @@ License along with the GNU C Library; if not, see <http://www.gnu.org/licenses/>. */ +#include <errno.h> +#include <nss.h> #include <stdio.h> #include <shadow.h> @@ -31,6 +33,13 @@ putspent (const struct spwd *p, FILE *stream) { int errors = 0; + if (p->sp_namp == NULL || !__nss_valid_field (p->sp_namp) + || !__nss_valid_field (p->sp_pwdp)) + { + __set_errno (EINVAL); + return -1; + } + flockfile (stream); if (fprintf (stream, "%s:%s:", p->sp_namp, _S (p->sp_pwdp)) < 0) |