about summary refs log tree commit diff
path: root/nss/nss_files/files-hosts.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2003-02-12 07:44:59 +0000
committerUlrich Drepper <drepper@redhat.com>2003-02-12 07:44:59 +0000
commit969c9da7f7891a041c157a3b2139e92fa823f9f8 (patch)
treee05513f4479001639e4bc1f7e3586f3aba018f25 /nss/nss_files/files-hosts.c
parente5ffa64a7003b5886c85c6434ced62ebc468b40d (diff)
downloadglibc-969c9da7f7891a041c157a3b2139e92fa823f9f8.tar.gz
glibc-969c9da7f7891a041c157a3b2139e92fa823f9f8.tar.xz
glibc-969c9da7f7891a041c157a3b2139e92fa823f9f8.zip
Update.
2003-02-11  Ulrich Drepper  <drepper@redhat.com>

	* nss/nss_files/files-hosts.c (HOST_DB_LOOKUP): Compute alignment
	correctly.  Reported by Thorsten Kukuk.
Diffstat (limited to 'nss/nss_files/files-hosts.c')
-rw-r--r--nss/nss_files/files-hosts.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/nss/nss_files/files-hosts.c b/nss/nss_files/files-hosts.c
index 12ad9cf5a5..96e410f850 100644
--- a/nss/nss_files/files-hosts.c
+++ b/nss/nss_files/files-hosts.c
@@ -1,5 +1,5 @@
 /* Hosts file parser in nss_files module.
-   Copyright (C) 1996,1997,1998,1999,2000,2001 Free Software Foundation, Inc.
+   Copyright (C) 1996-2001, 2003 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
@@ -166,7 +166,11 @@ _nss_files_get##name##_r (proto,					      \
 		      newstrlen += strlen (tmp_result_buf.h_name) + 1;	      \
 		    }							      \
 									      \
-		  /* Now we can check whether the buffer is large enough.  */ \
+		  /* Make sure bufferend is aligned.  */		      \
+		  assert ((bufferend - (char *) 0) % sizeof (char *) == 0);   \
+									      \
+		  /* Now we can check whether the buffer is large enough.     \
+		     16 is the maximal size of the IP address.  */	      \
 		  if (bufferend + 16 + (naddrs + 2) * sizeof (char *)	      \
 		      + roundup (newstrlen, sizeof (char *))		      \
 		      + (naliases + newaliases + 1) * sizeof (char *)	      \
@@ -217,7 +221,7 @@ _nss_files_get##name##_r (proto,					      \
 		  /* Round up the buffer end address.  */		      \
 		  bufferend += (sizeof (char *)				      \
 				- ((bufferend - (char *) 0)		      \
-				   % sizeof (char *)));			      \
+				   % sizeof (char *))) % sizeof (char *);     \
 									      \
 		  /* Now the new address.  */				      \
 		  new_h_addr_list[naddrs++] =				      \