about summary refs log tree commit diff
path: root/nss
diff options
context:
space:
mode:
Diffstat (limited to 'nss')
-rw-r--r--nss/getXXbyYY.c3
-rw-r--r--nss/getXXent.c7
-rw-r--r--nss/nss_files/files-XXX.c7
-rw-r--r--nss/nss_files/files-parse.c31
4 files changed, 26 insertions, 22 deletions
diff --git a/nss/getXXbyYY.c b/nss/getXXbyYY.c
index 542072be25..f81df05381 100644
--- a/nss/getXXbyYY.c
+++ b/nss/getXXbyYY.c
@@ -122,6 +122,9 @@ FUNCTION_NAME (ADD_PARAMS)
       buffer = new_buf;
     }
 
+  if (buffer == NULL)
+    result = NULL;
+
 #ifdef HANDLE_DIGITS_DOTS
 done:
 #endif
diff --git a/nss/getXXent.c b/nss/getXXent.c
index f180171150..eeb03dfa37 100644
--- a/nss/getXXent.c
+++ b/nss/getXXent.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1996 Free Software Foundation, Inc.
+/* Copyright (C) 1996, 1997 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
@@ -69,7 +69,7 @@ GETFUNC_NAME (void)
   static char *buffer;
   static size_t buffer_size;
   static LOOKUP_TYPE resbuf;
-  LOOKUP_TYPE *result = NULL;
+  LOOKUP_TYPE *result;
   int save;
 
   /* Get lock.  */
@@ -103,6 +103,9 @@ GETFUNC_NAME (void)
       buffer = new_buf;
     }
 
+  if (buffer == NULL)
+    result = NULL;
+
   /* Release lock.  Preserve error value.  */
   save = errno;
   __libc_lock_unlock (lock);
diff --git a/nss/nss_files/files-XXX.c b/nss/nss_files/files-XXX.c
index d3ff520227..7472496a10 100644
--- a/nss/nss_files/files-XXX.c
+++ b/nss/nss_files/files-XXX.c
@@ -1,5 +1,5 @@
 /* Common code for file-based databases in nss_files module.
-   Copyright (C) 1996 Free Software Foundation, Inc.
+   Copyright (C) 1996, 1997 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
@@ -146,6 +146,7 @@ internal_getent (struct STRUCTURE *result,
   char *p;
   struct parser_data *data = (void *) buffer;
   int linebuflen = buffer + buflen - data->linebuffer;
+  int parse_result;
 
   if (buflen < (int) sizeof *data + 1)
     {
@@ -182,10 +183,10 @@ internal_getent (struct STRUCTURE *result,
   while (*p == '\0' || *p == '#' /* Ignore empty and comment lines.  */
 	 /* Parse the line.  If it is invalid, loop to get the next
 	    line of the file to parse.  */
-	 || ! parse_line (p, result, data, buflen));
+	 || ! (parse_result = parse_line (p, result, data, buflen)));
 
   /* Filled in RESULT with the next entry from the database file.  */
-  return NSS_STATUS_SUCCESS;
+  return parse_result == -1 ? NSS_STATUS_TRYAGAIN : NSS_STATUS_SUCCESS;
 }
 
 
diff --git a/nss/nss_files/files-parse.c b/nss/nss_files/files-parse.c
index 2e84d762f0..acf673da90 100644
--- a/nss/nss_files/files-parse.c
+++ b/nss/nss_files/files-parse.c
@@ -1,5 +1,5 @@
 /* Common code for file-based database parsers in nss_files module.
-   Copyright (C) 1996 Free Software Foundation, Inc.
+   Copyright (C) 1996, 1997 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
@@ -152,7 +152,7 @@ parse_line (char *line, struct STRUCTURE *result,			      \
   if (list)								      \
     result->TRAILING_LIST_MEMBER = list;				      \
   else 									      \
-    return 0;								      \
+    return -1;		/* -1 indicates we ran out of space.  */	      \
 }
 
 static inline char **
@@ -189,29 +189,26 @@ parse_list (char *line, struct parser_data *data, size_t datalen)
       if (*line == '\0')
 	break;
 
+      /* Skip leading white space.  This might not be portable but useful.  */
+      while (isspace (*line))
+	++line;
+
       elt = line;
       while (1)
 	{
-	  if (TRAILING_LIST_SEPARATOR_P (*line))
-	    {
-	      *p++ = elt;
-	      *line = '\0';
-	      do
-		++line;
-	      while (isspace (*line));
-	      elt = line;
-	    }
-	  else if (*line == '\0')
+	  if (*line == '\0' || TRAILING_LIST_SEPARATOR_P (*line))
 	    {
-	      /* End of the line.  */
+	      /* End of the next entry.  */
 	      if (line > elt)
-		/* Last element.  */
+		/* We really found some data.  */
 		*p++ = elt;
-	      *line = '\0';
+
+	      /* Terminate string if necessary.  */
+	      if (*line != '\0')
+		*line++ = '\0';
 	      break;
 	    }
-	  else
-	    ++line;
+	  ++line;
 	}
     }
   *p = NULL;