Browse code

better handling of network errors

git-svn: trunk@2690

Tomasz Kojm authored on 2007/02/10 06:27:25
Showing 2 changed files
... ...
@@ -1,4 +1,9 @@
1
+Fri Feb  9 22:25:24 CET 2007 (tk)
2
+---------------------------------
3
+  * sigtool/sigtool.c: better handling of network errors
4
+
1 5
 Fri Feb  9 21:12:28 CET 2007 (acab)
6
+-----------------------------------
2 7
   * libclamav: Fix win32 compilation error in upack and mew - thanks Nigel
3 8
   
4 9
 Fri Feb  9 17:57:15 GMT 2007 (njh)
... ...
@@ -298,18 +298,23 @@ static char *getdsig(const char *host, const char *user, const char *data, unsig
298 298
     memset(pass, 0, strlen(pass));
299 299
     memset(buff, 0, sizeof(buff));
300 300
 
301
-    if((bread = read(sockd, buff, sizeof(buff))) > 0) {
301
+    if((bread = cli_readn(sockd, buff, sizeof(buff))) > 0) {
302 302
 	if(!strstr(buff, "Signature:")) {
303 303
 	    mprintf("!getdsig: Error generating digital signature\n");
304 304
 	    mprintf("!getdsig: Answer from remote server: %s\n", buff);
305 305
 	    close(sockd);
306 306
 	    return NULL;
307 307
 	} else {
308
-	   /* mprintf("Signature received (length = %d)\n", strlen(buff) - 10); */
308
+	    mprintf("Signature received (length = %u)\n", strlen(buff) - 10);
309 309
 	}
310
+    } else {
311
+	mprintf("!getdsig: Communication error with remote server\n");
312
+	close(sockd);
313
+	return NULL;
310 314
     }
311 315
 
312 316
     close(sockd);
317
+
313 318
     pt = buff;
314 319
     pt += 10;
315 320
     return strdup(pt);