X-Git-Url: http://sru.miketaylor.org.uk/?a=blobdiff_plain;f=src%2Fyaz-proxy.cpp;h=6170a1e28238907fab97554e70a33cbe64eaf6e1;hb=2c1361022c99ef0dccedad47cfe6e6bbd0a0a5ee;hp=935e453808203b20c16a58220d3c94bb147e6a1d;hpb=2bab0500e690612c044b1d9f87a0f03bc1640743;p=yazproxy-moved-to-github.git diff --git a/src/yaz-proxy.cpp b/src/yaz-proxy.cpp index 935e453..6170a1e 100644 --- a/src/yaz-proxy.cpp +++ b/src/yaz-proxy.cpp @@ -1,5 +1,5 @@ -/* $Id: yaz-proxy.cpp,v 1.14 2004-12-13 20:52:33 adam Exp $ - Copyright (c) 1998-2004, Index Data. +/* $Id: yaz-proxy.cpp,v 1.19 2005-02-07 13:29:38 adam Exp $ + Copyright (c) 1998-2005, Index Data. This file is part of the yaz-proxy. @@ -20,17 +20,25 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA */ #ifdef WIN32 -#else -#include +#define HAVE_SYS_STAT_H 1 +#define HAVE_SYS_TYPES_H 1 #endif -#if HAVE_GETTIMEOFDAY +#if HAVE_UNISTD_H +#include +#endif +#if HAVE_SYS_TIME_H #include #endif +#if HAVE_SYS_TYPES_H +#include +#endif +#if HAVE_SYS_STAT_H +#include +#endif #include #include -#include #include #include @@ -688,8 +696,8 @@ int Yaz_Proxy::convert_xsl(Z_NamePlusRecordList *p, Z_APDU *apdu) void Yaz_Proxy::convert_xsl_delay() { - Z_NamePlusRecord *npr = m_stylesheet_nprl->records[m_stylesheet_offset]; #if HAVE_XSLT + Z_NamePlusRecord *npr = m_stylesheet_nprl->records[m_stylesheet_offset]; if (npr->which == Z_NamePlusRecord_databaseRecord) { Z_External *r = npr->u.databaseRecord; @@ -1886,32 +1894,41 @@ void Yaz_Proxy::srw_get_client(const char *db, const char **backend_db) int Yaz_Proxy::file_access(Z_HTTP_Request *hreq) { + struct stat sbuf; yaz_log(YLOG_LOG, "file_access"); if (strcmp(hreq->method, "GET")) return 0; - struct stat sbuf; if (hreq->path[0] != '/') { - yaz_log(YLOG_WARN, "Path != /"); + yaz_log(YLOG_WARN, "Bad path: %s", hreq->path); return 0; } const char *cp = hreq->path; while (*cp) { if (*cp == '/' && strchr("/.", cp[1])) + { + yaz_log(YLOG_WARN, "Bad path: %s", hreq->path); return 0; + } cp++; } const char *fname = hreq->path+1; if (stat(fname, &sbuf)) { - yaz_log(YLOG_WARN, "stat %s failed", fname); + yaz_log(YLOG_WARN|YLOG_ERRNO, "%s: stat failed", fname); return 0; } if ((sbuf.st_mode & S_IFMT) != S_IFREG) + { + yaz_log(YLOG_WARN, "%s: not a regular file", fname); return 0; + } if (sbuf.st_size > (off_t) 1000000) + { + yaz_log(YLOG_WARN, "%s: too large for transfer", fname); return 0; + } ODR o = odr_encode(); Yaz_ProxyConfig *cfg = check_reconfigure(); @@ -2391,7 +2408,7 @@ void Yaz_Proxy::handle_incoming_Z_PDU(Z_APDU *apdu) // delete other info construct completely if 0 elements get_otherInfoAPDU(apdu, &oi); - if (*oi && (*oi)->num_elements == 0) + if (oi && *oi && (*oi)->num_elements == 0) *oi = 0; if (apdu->which == Z_APDU_presentRequest &&