Commit Graph

411 Commits

Author SHA1 Message Date
Siddhesh Poyarekar d7b00f9810 Fix invalid memory access when parsing netgroup files with blank lines (BZ #16506)
The netgroups file parsing code tries to access the character before
the newline in parsed lines to see if it is a backslash (\).  This
results in an access before the block allocated for the line if the
line is blank, i.e. does not have anything other than the newline
character.  This doesn't seem like it will cause any crashes because
the byte belongs to the malloc metadata block and hence access to it
will always succeed.

There could be an invalid alteration in code flow where a blank line
is seen as a continuation due to the preceding byte *happening* to be
'\\'.  This could be done by interposing malloc, but that's not really
a security problem since one could interpose getnetgrent_r itself and
achieve a similar 'exploit'.

The possibility of actually exploiting this is remote to impossible
since it also requires the previous line to end with a '\\', which
would happen only on invalid configurations.
2014-01-27 16:49:33 +05:30
Allan McRae 88726d48af Update remaining copyright dates
Update copyright years that are not handled by scripts/update-copyright.
2014-01-01 22:02:55 +10:00
Allan McRae d4697bc93d Update copyright notices with scripts/update-copyrights 2014-01-01 22:00:23 +10:00
Siddhesh Poyarekar df3aedaf38 Use herrnop directly
H_ERRNO_ARGS is unnecessary since we this file is specifically for
hosts lookup.
2013-12-02 20:06:20 +05:30
Siddhesh Poyarekar 5a4c6d53f5 Get canonical name in getaddrinfo from hosts file for AF_INET (fixes 16077)
AF_INET lookup in hosts file uses _nss_files_gethostbyname2_r, which
is not capable of returning a canonical name if it has found one.
This change adds _nss_files_gethostbyname3_r, which wraps around
_nss_files_gethostbyname2_r and then returns result.h_name as the
canonical name.
2013-11-28 17:18:12 +05:30
Ondřej Bílka e4368156e6 Make getent services compliant with RFC 6335 section 5.1 Fixes bug 15374
The RFC 6335 allows services that start with digit (like 3com-tsmux).
These were parsed as port number which this patch fixes.
2013-11-07 12:51:44 +01:00
Siddhesh Poyarekar 977f4b31b7 Fix reads for sizes larger than INT_MAX in AF_INET lookup
Currently for AF_INET lookups from the hosts file, buffer sizes larger
than INT_MAX silently overflow and may result in access beyond bounds
of a buffer.  This happens when the number of results in an AF_INET
lookup in /etc/hosts are very large.

There are two aspects to the problem.  One problem is that the size
computed from the buffer size is stored into an int, which results in
overflow for large sizes.  Additionally, even if this size was
expanded, the function used to read content into the buffer (fgets)
accepts only int sizes.  As a result, the fix is to have a function
wrap around fgets that calls it multiple times with int sizes if
necessary.
2013-10-30 16:19:40 +05:30
Roland McGrath 59d112a4c7 Use proper #include for xdecrypt declarations. 2013-08-26 15:04:02 -07:00
Ondrej Bilka 350635a59a Fix leading whitespaces. 2013-06-06 20:36:07 +02:00
Joseph Myers fab7ce3f5b Link extra-libs consistently with libc and ld.so. 2013-05-31 16:16:33 +00:00
Siddhesh Poyarekar 3d04f5db20 Set EAI_SYSTEM only when h_errno is NETDB_INTERNAL
Fixes BZ #15339.

NSS_STATUS_UNAVAIL may mean that a necessary input resource is not
available.  This could occur in a number of cases including when the
network is down, system runs out of file descriptors, etc.  The
correct differentiator in such a case is the h_errno, which gives the
nature of failure.  In case of failures other than a simple 'not
found', we set h_errno as NETDB_INTERNAL and let errno be the
identifier for the exact error.
2013-05-21 21:54:41 +05:30
Andreas Schwab d5dd6189d5 Fix parsing of numeric hosts in gethostbyname_r 2013-05-21 12:26:33 +02:00
Ryan S. Arnold e054f49430 Add #include <stdint.h> for uint[32|64]_t usage (except installed headers). 2013-05-16 11:32:54 -05:00
Andreas Schwab 7ed3f4e859 Remove non-standard initialisation of flexible array member
This avoids GCC bug 28865.
2013-04-23 10:31:03 +02:00
Jan-Benedict Glaw d34c915826 Fix getent to call endspent rather than endpwent for shadow database. 2013-04-22 10:44:31 -07:00
Roland McGrath 0e2b9cdde7 BZ#14812: Add missing translation marker on some argp option argument names in utilities. 2013-03-18 14:59:47 -07:00
Mike Frysinger 6ff444c418 unify xmalloc prototypes & friends
These prototypes are duplicated in many places.  Add a dedicated
header for holding prototypes for program-specific functions to
avoid that.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2013-02-18 17:16:05 -05:00
Roland McGrath f1d70dad53 Remove lots of inline keywords. 2013-02-07 14:44:18 -08:00
Joseph Myers 568035b787 Update copyright notices with scripts/update-copyrights. 2013-01-02 19:05:09 +00:00
David S. Miller 0549fbba96 Update copyright years.
* catgets/gencat.c: Update copyright year.
	* csu/version.c: Likewise.
	* debug/catchsegv.sh: Likewise.
	* debug/pcprofiledump.c: Likewise.
	* debug/xtrace.sh: Likewise.
	* elf/ldconfig.c: Likewise.
	* elf/ldd.bash.in: Likewise.
	* elf/pldd.c: Likewise.
	* elf/sotruss.ksh: Likewise.
	* elf/sprof.c: Likewise.
	* iconv/iconv_prog.c: Likewise.
	* iconv/iconvconfig.c: Likewise.
	* locale/programs/locale.c: Likewise.
	* locale/programs/localedef.c: Likewise.
	* login/programs/pt_chown.c: Likewise.
	* malloc/memusage.sh: Likewise.
	* malloc/memusagestat.c: Likewise.
	* malloc/mtrace.pl: Likewise.
	* nscd/nscd.c: Likewise.
	* nss/getent.c: Likewise.
	* nss/makedb.c: Likewise.
	* posix/getconf.c: Likewise.
2013-01-01 00:11:43 -08:00
Siddhesh Poyarekar 0817d63dd1 Fix hashtable size calculation when database has exactly one record
The hash function needs a hashtable of at least size 3 or greater.
2012-11-28 06:45:50 +05:30
Siddhesh Poyarekar cfde9b463d Return EAI_SYSTEM if we're out of file descriptors
Resolves BZ #14719.
2012-11-19 13:02:48 +05:30
Joseph Myers 8b748aed2a Support --with-pkgversion and --with-bugurl. 2012-11-09 22:13:45 +00:00
Chris Metcalf 017678433c Suppress incorrect link warnings for NSS symbols
When glibc is built with --enable-static-nss, the warning that
using NSS symbols requires the nss shared objects to be present
is no longer true, as those symbols are built into libc.  Suppress
the warning for those symbols by providing a new macro
(nss_interface_function) for the NSS functions that is defined as
static_link_warning in the normal case, and empty for static NSS.
2012-10-30 14:14:33 -04:00
Roland McGrath 6bacf05bfd Quiet make warning under --disable-shared. 2012-09-28 14:33:40 -07:00
Roland McGrath b1c608fe20 Avoid more warnings in nsswitch.c 2012-09-28 13:48:14 -07:00
Roland McGrath d3b9fd9e8d Avoid unused static function warning in nsswitch.c. 2012-09-28 13:23:00 -07:00
Roland McGrath 3cc3ef96d6 BZ#13696: Add --disable-nscd configure option. 2012-08-22 13:31:12 -07:00
Jim Meyering c5f80821ab getXXbyYY_r.c: Fix comment typo: s/FUNCTION_NAME/FUNCTION2_NAME/ 2012-08-04 15:59:40 +02:00
Roland McGrath 40ce302d37 Conditionalize use of PTR_MANGLE. 2012-07-31 09:42:06 -07:00
Roland McGrath bea9b19322 Fix lots of bitrot for stub configurations. 2012-07-30 16:34:33 -07:00
Jeroen van Bemmel 7b6e99be77 Avoid duplicate DNS requests if answer is longer than a implementation
limit

        [BZ #14307]
        * sysdeps/posix/getaddrinfo.c (gaih_inet): Increase the size of
        the temporary buffer used to invoke __gethostbyname2_r,
        __gethostbyaddr_r and gethostbyname4_r to make room for struct
        host_data / struct gaih_addrtuple.
        * resolv/nss_dns/dns-host.c (global scope): Move definition of
        implementation constants MAX_NR_ALIASES and MAX_NR_ADDRS to
        header file nss/nsswitch.h.
        * nss/nsswitch.h (global scope): Add definition of implementation
        constants MAX_NR_ALIASES and MAX_NR_ADDRS (moved from
        resolv/nss_dns/dns-host.c).
2012-07-12 11:31:48 +05:30
Paul Pluzhnikov d44638b0a7 For [BZ#14122], plug memory leaks in nsswitch.c. 2012-05-22 13:09:27 -07:00
Thomas Schwinge 8069478040 Hurd: mmap deficiencies 2012-05-10 15:57:26 -07:00
Thomas Schwinge e468f8a3a7 Hurd: Add missing includes 2012-05-10 15:57:25 -07:00
Paul Pluzhnikov 62470f605e 2012-04-06 Paul Pluzhnikov <ppluzhnikov@google.com>
[BZ #13895]
	* nss/nsswitch.c (nss_load_library, __nss_lookup_function): Avoid
	extra indirection.
	* nss/Makefile (tests-static, tests): Add tst-nss-static.
	* nss/tst-nss-static.c: New.
2012-04-06 13:49:35 -07:00
Andreas Jaeger 2c040eff83 Add missing include file
Compiling on Linux/i586 I get these warnings:
nss_db/db-initgroups.c:60:3: warning: implicit declaration of function
'strlen' [-Wimplicit-function-declaration]
nss_db/db-initgroups.c:74:7: warning: implicit declaration of function
'strncmp' [-Wimplicit-function-declaration]

Fixed with inclusion of <string.h>
2012-04-06 21:09:36 +02:00
Jeff Law 6a9b9c02fa 2012-03-23 Jeff Law <law@redhat.com>
* nss/getnssent.c (__nss_getent): Fix typo.
2012-03-23 14:56:42 -06:00
Paul Pluzhnikov 3ff4252677 2012-03-23 Daniel Jacobowitz <dmj@google.com>
Paul Pluzhnikov  <ppluzhnikov@google.com>

	[BZ #6528]
	* grp/Makefile (otherlibs): Don't set it.
	* inet/Makefile (otherlibs): Likewise.
	* login/Makefile (otherlibs): Likewise.
	* nscd/Makefile (otherlibs): Likewise.
	* posix/Makefile (otherlibs): Likewise.
	* pwd/Makefile (otherlibs): Likewise.
	* rt/Makefile (otherlibs): Likewise.
	* sunrpc/Makefile (otherlibs): Likewise.
	* nss/Makefile (otherlibs): Likewise.
	Add libnss_files to routines and static-only-routines.
	($(objpfx)getent): Remove rule.
	* resolv/Makefile: Add libnss_dns and libresolv to routines and
	static-only-routines.
2012-03-23 09:47:03 -07:00
David S. Miller 09a3453f63 Add missing string.h include for strcpy calls.
* nss/nss_db/db-init.c: Include string.h
2012-03-13 00:41:37 -07:00
Ulrich Drepper a4300c7a4d Remove distribute variable from Makefiles 2012-03-07 05:17:13 -05:00
Ulrich Drepper a000466f5e Add missing gshadow handling in __nss_configure_lookup 2012-03-06 21:55:18 -05:00
Paul Eggert 59ba27a63a Replace FSF snail mail address with URLs. 2012-02-09 23:18:22 +00:00
Ulrich Drepper ec09c1c410 Optimize xmalloc, xcalloc, xrealloc, and xstrdup
Add alloc_size attribute and apply consistently the malloc attribute
to xmalloc, xcalloc, xrealloc, and xstrdup.
2012-01-08 21:19:43 -05:00
Ulrich Drepper a784e50247 Remove pre-ISO C support
No more __const.
2012-01-07 23:57:22 -05:00
Ulrich Drepper a316c1f682 Also update new programs 2012-01-01 07:16:32 -05:00
Ulrich Drepper 81fb02b046 Update copyright year 2012-01-01 05:50:05 -05:00
Ulrich Drepper 312be3f9f5 Clean up internal fopen uses
No need to ever not use c and e.
2011-11-15 04:24:42 -05:00
Andreas Schwab 98591e5820 Fix db makefile rule for group.db 2011-11-11 14:44:21 +01:00
Andreas Schwab ae1bc2fa1c Fix buffer allocation in files initgroups handler 2011-11-07 11:49:51 +01:00