File: libssh2-banner-wait.diff

package info (click to toggle)
medusa 1.3-1
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 1,488 kB
  • ctags: 1,061
  • sloc: ansic: 11,422; sh: 8,589; makefile: 118; perl: 80
file content (23 lines) | stat: -rw-r--r-- 675 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
diff -urb libssh2-0.11/src/session.c libssh2-0.11-jmk/src/session.c
--- libssh2-0.11/src/session.c	2005-06-27 17:24:29.000000000 -0500
+++ libssh2-0.11-jmk/src/session.c	2005-11-10 20:27:34.000000000 -0600
@@ -95,12 +95,19 @@
 {
 	char banner[256];
 	int banner_len = 0;
+	int wait_count = 0;
 
 	while ((banner_len < sizeof(banner)) &&
 			((banner_len == 0) || (banner[banner_len-1] != '\n'))) {
 		char c = '\0';
 		int ret;
 
+		wait_count++;
+
+		/* If server is not responding, don't wait in loop forever */
+		if (wait_count > 1000)
+			return 1;
+
 		ret = recv(session->socket_fd, &c, 1, LIBSSH2_SOCKET_RECV_FLAGS(session));
 
 		if ((ret < 0) && (ret != EAGAIN)) {