added target debian;
[pazpar2-moved-to-github.git] / src / config.c
index 779ea57..247df8a 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: config.c,v 1.36 2007-06-06 11:56:35 marc Exp $
+/* $Id: config.c,v 1.38 2007-07-25 11:00:26 adam Exp $
    Copyright (c) 2006-2007, Index Data.
 
 This file is part of Pazpar2.
@@ -19,7 +19,7 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
 02111-1307, USA.
  */
 
-/* $Id: config.c,v 1.36 2007-06-06 11:56:35 marc Exp $ */
+/* $Id: config.c,v 1.38 2007-07-25 11:00:26 adam Exp $ */
 
 #include <string.h>
 
@@ -35,6 +35,7 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
 
 #include <yaz/yaz-util.h>
 #include <yaz/nmem.h>
+#include <yaz/snprintf.h>
 
 #define CONFIG_NOEXTERNS
 #include "config.h"
@@ -405,8 +406,6 @@ static struct conf_server *parse_server(xmlNode *node)
     server->proxy_host = 0;
     server->proxy_port = 0;
     server->myurl = 0;
-    //server->zproxy_host = 0;
-    //server->zproxy_port = 0;
     server->service = 0;
     server->next = 0;
     server->settings = 0;
@@ -511,7 +510,10 @@ static struct conf_server *parse_server(xmlNode *node)
 xsltStylesheet *conf_load_stylesheet(const char *fname)
 {
     char path[256];
-    sprintf(path, "%s/%s", confdir, fname);
+    if (*fname == '/')
+        yaz_snprintf(path, sizeof(path), fname);
+    else
+        yaz_snprintf(path, sizeof(path), "%s/%s", confdir, fname);
     return xsltParseStylesheetFile((xmlChar *) path);
 }
 
@@ -610,6 +612,8 @@ int read_config(const char *fname)
     if ((p = strrchr(fname, '/')))
     {
         int len = p - fname;
+        if (len >= sizeof(confdir))
+            len = sizeof(confdir)-1;
         strncpy(confdir, fname, len);
         confdir[len] = '\0';
     }