tags 325177 patch
thanks
This bug has been driving me crazy, so I took a quick look: it's caused
by 'cachestr' being used uninitialized in cache_store() if jwhois is
started with -f. You can't call strlen() on an uninitialized pointer
and expect things to work...
This patch fixes the problem:
diff -urN jwhois-3.2.3.orig/src/jwhois.c jwhois-3.2.3/src/jwhois.c
--- jwhois-3.2.3.orig/src/jwhois.c 2005-01-15 17:10:14.000000000 +0100
+++ jwhois-3.2.3/src/jwhois.c 2005-09-21 11:57:53.000000000 +0200
@@ -131,16 +131,17 @@
text = NULL;
#ifndef NOCACHE
+ cachestr = malloc(strlen(wq.query) + strlen(wq.host) + 1);
+ if (!cachestr)
+ {
+ printf("[%s]\n", _("Error allocating memory"));
+ exit(1);
+ }
+ snprintf(cachestr, strlen(wq.query) + strlen(wq.host) + 1, "%s:%s",
+ wq.host, wq.query);
+
if (!forcelookup && cache) {
if (verbose>1) printf("[Looking up entry in cache]\n");
- cachestr = malloc(strlen(wq.query) + strlen(wq.host) + 1);
- if (!cachestr)
- {
- printf("[%s]\n", _("Error allocating memory"));
- exit(1);
- }
- snprintf(cachestr, strlen(wq.query) + strlen(wq.host) + 1, "%s:%s",
- wq.host, wq.query);
ret = cache_read(cachestr, &text);
if (ret < 0)
{
Note that gcc notices the problem:
| jwhois.c: In function 'main':
| jwhois.c:69: warning: 'cachestr' may be used uninitialized in this function
Also, jwhois doesn't seem to be freeing any of the zones it allocates:
doing so would catch this kind of bug.
Thanks,
--
,''`.
: :' : Romain Francoise <[EMAIL PROTECTED]>
`. `' http://people.debian.org/~rfrancoise/
`-
--
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]