Update of /cvsroot/monetdb/sql/src/backends/monet5
In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv412
Modified Files:
monetdb.mx
Log Message:
Fix crashes in monetdb discover when there are more remote databases than fit
in a single block.
U monetdb.mx
Index: monetdb.mx
===================================================================
RCS file: /cvsroot/monetdb/sql/src/backends/monet5/monetdb.mx,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -d -r1.30 -r1.31
--- monetdb.mx 26 Oct 2008 07:43:23 -0000 1.30
+++ monetdb.mx 27 Oct 2008 14:51:41 -0000 1.31
@@ -563,7 +563,7 @@
char buf[256];
char *p, *q;
int len;
- int pos = 0;
+ int pos;
(void)argc;
(void)argv;
@@ -592,37 +592,60 @@
}
printf(" name location\n");
- /* Send the pass phrase to unlock the information available in
+ /* Send the pass phrase to unlock the information available in
* merovingian. Anelosimus eximius is a social species of spiders,
* which help each other, just like merovingians do among each
* other. */
len = snprintf(buf, sizeof(buf), "anelosimus eximius\n");
send(sock, buf, len, 0);
- while ((len = recv(sock, buf + pos, sizeof(buf) - 1 - pos, 0)) > 0) {
- buf[pos + len] = '\0';
+ pos = 0;
+ len = recv(sock, buf, sizeof(buf) - 1, 0);
+ if (len <= 0) {
+ fprintf(stderr, "discover: error while reading from
merovingian\n");
+ exit(2);
+ }
+ buf[len] = '\0';
+ do {
if ((p = strchr(buf, '\n')) == NULL) {
- /* no newline in this block too large, warn and discard
*/
- printf("discover: WARNING: discarding (too long?) line:
%s\n", buf);
- pos = 0;
+ if (len == sizeof(buf) - 1) {
+ /* no newline in this block, too large, warn
and discard */
+ printf("discover: WARNING: discarding (too
long?) line: %s\n",
+ buf);
+ pos = 0;
+ } else {
+ pos = len;
+ }
+ len = recv(sock, buf + pos, sizeof(buf) - 1 - pos, 0);
+ /* if there is no more... */
+ if (len == 0) {
+ break;
+ } else if (len < 0) {
+ fprintf(stderr, "discover: error while reading "
+ "from merovingian\n");
+ exit(2);
+ }
+ len += pos;
+ buf[len] = '\0';
continue;
}
*p++ = '\0';
+
if ((q = strchr(buf, '\t')) == NULL) {
/* doesn't look correct */
printf("discover: WARNING: discarding incorrect line:
%s\n", buf);
- memmove(buf, p, len - (p - buf));
- pos = len - (p - buf);
+ len -= p - buf;
+ memmove(buf, p, len + 1 /* include \0 */);
continue;
}
*q++ = '\0';
+
+ /* show what we found */
printf("%-14s %s\n", buf, q);
- memmove(buf, p, len - (p - buf));
- pos = len - (p - buf);
- }
- if (len < 0) {
- fprintf(stderr, "discover: error while reading from from
merovingian\n");
- exit(2);
- }
+
+ /* move it away */
+ len -= p - buf;
+ memmove(buf, p, len + 1 /* include \0 */);
+ } while (1);
close(sock);
}
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Monetdb-sql-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/monetdb-sql-checkins