[Opendnssec-commits] [svn.opendnssec.org/svn/dnssec] r5455 - in branches/OpenDNSSEC-adapters/signer/src: . daemon

Matthijs Mekking matthijs at nlnetlabs.nl
Tue Aug 23 14:05:36 CEST 2011


Author: matthijs
Date: 2011-08-23 14:05:35 +0200 (Tue, 23 Aug 2011)
New Revision: 5455

Modified:
   branches/OpenDNSSEC-adapters/signer/src/daemon/cmdhandler.c
   branches/OpenDNSSEC-adapters/signer/src/ods-signer.c
Log:
trim at the server side



Modified: branches/OpenDNSSEC-adapters/signer/src/daemon/cmdhandler.c
===================================================================
--- branches/OpenDNSSEC-adapters/signer/src/daemon/cmdhandler.c	2011-08-23 11:52:30 UTC (rev 5454)
+++ branches/OpenDNSSEC-adapters/signer/src/daemon/cmdhandler.c	2011-08-23 12:05:35 UTC (rev 5455)
@@ -670,12 +670,12 @@
 
 again:
     while ((n = read(sockfd, buf, ODS_SE_MAXLINE)) > 0) {
+        /* what if this number is smaller than the number of bytes requested? */
         buf[n-1] = '\0';
         n--;
-        if (n <= 0) {
-            return;
-        }
         ods_log_verbose("[%s] received command %s[%i]", cmdh_str, buf, n);
+        ods_str_trim(buf);
+        n = strlen(buf);
 
         if (n == 4 && strncmp(buf, "help", n) == 0) {
             ods_log_debug("[%s] help command", cmdh_str);
@@ -742,11 +742,10 @@
             } else {
                 cmdhandler_handle_cmd_verbosity(sockfd, cmdc, atoi(&buf[10]));
             }
-        } else {
+        } else if (n > 0) {
             ods_log_debug("[%s] unknown command", cmdh_str);
             cmdhandler_handle_cmd_unknown(sockfd, buf);
         }
-
         ods_log_debug("[%s] done handling command %s[%i]", cmdh_str, buf, n);
         (void)snprintf(buf, SE_CMDH_CMDLEN, "\ncmd> ");
         ods_writen(sockfd, buf, strlen(buf));

Modified: branches/OpenDNSSEC-adapters/signer/src/ods-signer.c
===================================================================
--- branches/OpenDNSSEC-adapters/signer/src/ods-signer.c	2011-08-23 11:52:30 UTC (rev 5454)
+++ branches/OpenDNSSEC-adapters/signer/src/ods-signer.c	2011-08-23 12:05:35 UTC (rev 5455)
@@ -168,11 +168,9 @@
                             "from daemon.\n");
                     exit(1);
                 }
-                
                 /* n >= SE_CLI_CMDLEN : and so it is safe to do buffer 
                     manipulations below. */
                 if (strncmp(buf+n-SE_CLI_CMDLEN,"\ncmd> ",SE_CLI_CMDLEN) == 0) {
-                
                     /* we have the full response */
                     n -= SE_CLI_CMDLEN;
                     buf[n] = '\0';
@@ -250,8 +248,6 @@
                 strncmp(buf, "quit", 4) == 0) {
                 return;
             }
-            ods_str_trim(buf);
-            n = strlen(buf);
             ods_writen(sockfd, buf, n);
         }
     }




More information about the Opendnssec-commits mailing list