diff options
author | Florian Weimer <fweimer@redhat.com> | 2015-10-02 11:34:13 +0200 |
---|---|---|
committer | Florian Weimer <fweimer@redhat.com> | 2015-10-02 11:34:13 +0200 |
commit | 676599b36a92f3c201c5682ee7a5caddd9f370a4 (patch) | |
tree | 6860752c26ccab76ee9db5e60ff465d1edf25feb /include | |
parent | b0f81637d5bda47be93bac34b68f429a12979321 (diff) | |
download | glibc-676599b36a92f3c201c5682ee7a5caddd9f370a4.tar.gz glibc-676599b36a92f3c201c5682ee7a5caddd9f370a4.tar.xz glibc-676599b36a92f3c201c5682ee7a5caddd9f370a4.zip |
Harden putpwent, putgrent, putspent, putspent against injection [BZ #18724]
This prevents injection of ':' and '\n' into output functions which use the NSS files database syntax. Critical fields (user/group names and file system paths) are checked strictly. For backwards compatibility, the GECOS field is rewritten instead. The getent program is adjusted to use the put*ent functions in libc, instead of local copies. This changes the behavior of getent if user names start with '-' or '+'.
Diffstat (limited to 'include')
-rw-r--r-- | include/nss.h | 13 | ||||
-rw-r--r-- | include/pwd.h | 2 |
2 files changed, 14 insertions, 1 deletions
diff --git a/include/nss.h b/include/nss.h index 0541335c18..1e8cc3910d 100644 --- a/include/nss.h +++ b/include/nss.h @@ -1 +1,14 @@ +#ifndef _NSS_H #include <nss/nss.h> + +#define NSS_INVALID_FIELD_CHARACTERS ":\n" +extern const char __nss_invalid_field_characters[] attribute_hidden; + +_Bool __nss_valid_field (const char *value) + attribute_hidden internal_function; +_Bool __nss_valid_list_field (char **list) + attribute_hidden internal_function; +const char *__nss_rewrite_field (const char *value, char **to_be_freed) + attribute_hidden internal_function; + +#endif /* _NSS_H */ diff --git a/include/pwd.h b/include/pwd.h index bd7fecc16e..3b0f72540c 100644 --- a/include/pwd.h +++ b/include/pwd.h @@ -24,7 +24,7 @@ extern int __fgetpwent_r (FILE * __stream, struct passwd *__resultbuf, char *__buffer, size_t __buflen, struct passwd **__result); -#include <nss/nss.h> +#include <nss.h> struct parser_data; extern int _nss_files_parse_pwent (char *line, struct passwd *result, |