changeset 9591:0774e217e8aa

Don't declare malloc, realloc, free. Don't include string.h or strings.h. Include des.h before krb.h. Do declare my_strstr. (getline): Really use my_strstr. Leave one empty place in server->buffer, and put a null at the end of the data in it.
author Richard M. Stallman <rms@gnu.org>
date Tue, 18 Oct 1994 07:34:59 +0000
parents f84a7b49021d
children 132798b0352b
files lib-src/pop.c
diffstat 1 files changed, 8 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/lib-src/pop.c	Tue Oct 18 06:35:19 1994 +0000
+++ b/lib-src/pop.c	Tue Oct 18 07:34:59 1994 +0000
@@ -26,10 +26,6 @@
 #include <pop.h>
 #ifdef sun
 #include <malloc.h>
-#else
-extern char *malloc (/* unsigned */);
-extern char *realloc (/* char *, unsigned */);
-extern void free (/* char * */);
 #endif
 #endif
 #ifdef HESIOD
@@ -43,15 +39,13 @@
 extern struct servent *hes_getservbyname (/* char *, char * */);
 #endif
 #include <pwd.h>
-#include <string.h>
-#include <strings.h>
 #include <netdb.h>
 #include <errno.h>
 #include <stdio.h>
 #ifdef KERBEROS
 #ifndef KRB5
+#include <des.h>
 #include <krb.h>
-#include <des.h>
 #else /* KRB5 */
 #include <krb5/krb5.h>
 #include <krb5/ext-proto.h>
@@ -85,6 +79,8 @@
 #endif
 static void pop_trash (/* popserver */);
 
+static char *my_strstr ();
+
 #define ERROR_MAX 80		/* a pretty arbitrary size */
 #define POP_PORT 110
 #define KPOP_PORT 1109
@@ -1171,7 +1167,7 @@
      
   if (server->data)
     {
-      char *cp = strstr (server->buffer + server->buffer_index, "\r\n");
+      char *cp = my_strstr (server->buffer + server->buffer_index, "\r\n");
       if (cp)
 	{
 	  int found;
@@ -1214,7 +1210,7 @@
 	    }
 	}
       ret = read (server->file, server->buffer + server->data,
-		  server->buffer_size - server->data);
+		  server->buffer_size - server->data - 1);
       if (ret < 0)
 	{
 	  strcpy (pop_error, GETLINE_ERROR);
@@ -1231,9 +1227,11 @@
 	}
       else
 	{
-	  char *cp = strstr (server->buffer, "\r\n");
+	  char *cp;
 	  server->data += ret;
+	  server->buffer[server->data] = '\0';
 	       
+	  cp = my_strstr (server->buffer, "\r\n");
 	  if (cp)
 	    {
 	      int data_used = (cp + 2) - server->buffer;