about summary refs log tree commit diff stats
path: root/WWW/Library/Implementation/HTWSRC.c
diff options
context:
space:
mode:
Diffstat (limited to 'WWW/Library/Implementation/HTWSRC.c')
-rw-r--r--WWW/Library/Implementation/HTWSRC.c31
1 files changed, 18 insertions, 13 deletions
diff --git a/WWW/Library/Implementation/HTWSRC.c b/WWW/Library/Implementation/HTWSRC.c
index 7e1d899c..4fca40ca 100644
--- a/WWW/Library/Implementation/HTWSRC.c
+++ b/WWW/Library/Implementation/HTWSRC.c
@@ -244,28 +244,32 @@ PRIVATE void WSRCParser_put_character ARGS2(HTStream*, me, char, c)
 PRIVATE BOOL write_cache ARGS1(HTStream *, me)
 {
     FILE * fp;
-    char cache_file_name[LY_MAXPATH];
+    char * cache_file_name = NULL;
     char * www_database;
+    int result = NO;
+
     if (!me->par_value[PAR_DATABASE_NAME]
 	|| !me->par_value[PAR_IP_NAME]
 	) return NO;
 
     www_database = HTEscape(me->par_value[PAR_DATABASE_NAME], URL_XALPHAS);
-    sprintf(cache_file_name, "%sWSRC-%s:%s:%.100s.txt",
+    HTSprintf0(&cache_file_name, "%sWSRC-%s:%s:%.100s.txt",
 	CACHE_FILE_PREFIX,
 	me->par_value[PAR_IP_NAME],
 	me->par_value[PAR_TCP_PORT] ? me->par_value[PAR_TCP_PORT] : "210",
 	www_database);
+
+    if ((fp = fopen(cache_file_name, "w")) != 0) {
+	result = YES;
+	if (me->par_value[PAR_DESCRIPTION])
+	    fputs(me->par_value[PAR_DESCRIPTION], fp);
+	else
+	    fputs("Description not available\n", fp);
+	fclose(fp);
+    }
     FREE(www_database);
-    fp = fopen(cache_file_name, "w");
-    if (!fp) return NO;
-
-    if (me->par_value[PAR_DESCRIPTION])
-	fputs(me->par_value[PAR_DESCRIPTION], fp);
-    else
-	fputs("Description not available\n", fp);
-    fclose(fp);
-    return YES;
+    FREE(cache_file_name);
+    return result;
 }
 #endif
 
@@ -329,11 +333,11 @@ PRIVATE void WSRC_gen_html ARGS2(HTStream *, me, BOOL, source_file)
 	if (me->par_value[PAR_IP_NAME] &&
 	    me->par_value[PAR_DATABASE_NAME]) {
 
-	    char WSRC_address[256];
+	    char * WSRC_address = NULL;
 	    char * www_database;
 	    www_database = HTEscape(me->par_value[PAR_DATABASE_NAME],
 		URL_XALPHAS);
-	    sprintf(WSRC_address, "wais://%s%s%s/%s",
+	    HTSprintf0(&WSRC_address, "wais://%s%s%s/%s",
 		me->par_value[PAR_IP_NAME],
 		me->par_value[PAR_TCP_PORT] ? ":" : "",
 		me->par_value[PAR_TCP_PORT] ? me->par_value[PAR_TCP_PORT] :"",
@@ -346,6 +350,7 @@ PRIVATE void WSRC_gen_html ARGS2(HTStream *, me, BOOL, source_file)
 	    PUTS(gettext(" (or via proxy server, if defined)"));
 
 	    FREE(www_database);
+	    FREE(WSRC_address);
 
 	} else {
 	    give_parameter(me, PAR_IP_NAME);