[Initng-svn] r2327 - initng/plugins/ngc2

svn at initng.thinktux.net svn at initng.thinktux.net
Sun Dec 4 22:14:20 CET 2005


Author: jimmy
Date: Sun Dec  4 22:14:19 2005
New Revision: 2327

Modified:
   initng/plugins/ngc2/ngc2.c
Log:
Subject: [PATCH] Terminate the string fetched by read(2)
From: Enrico Scholz <enrico.scholz at informatik.tu-chemnitz.de>
Date: 1133713803 +0100

This patch terminates the string returned by 'read(2)' explicitly with
'\0' and wraps the read(2) syscall through TEMP_FAILURE_RETRY. This
patch fixes a potential endless loop too which would occur when read(2)
fails.

Bug #316



Modified: initng/plugins/ngc2/ngc2.c
==============================================================================
--- initng/plugins/ngc2/ngc2.c	(original)
+++ initng/plugins/ngc2/ngc2.c	Sun Dec  4 22:14:19 2005
@@ -266,9 +266,17 @@
 void command_fetch_string(void)
 {
     char tmp_read[MAX_RESCIVE_SIZE + 1];
+    ssize_t len;
 
-    while (read(sock, &tmp_read, MAX_RESCIVE_SIZE))
+    while ((len =
+            TEMP_FAILURE_RETRY(read(sock, &tmp_read, MAX_RESCIVE_SIZE))) > 0)
+    {
+        tmp_read[len] = '\0';
         printf("%s", tmp_read);
+    }
+
+    /* TODO: error handling??? */
+
     close_socket();
 }
 


More information about the Initng-svn mailing list