OSDN Git Service

fix source file size calculation.
authorvisor <visor@users.sourceforge.jp>
Sat, 4 Jul 2015 15:59:02 +0000 (00:59 +0900)
committervisor <visor@users.sourceforge.jp>
Sat, 4 Jul 2015 15:59:02 +0000 (00:59 +0900)
config.h
lib/app.cc
lib/formfile.cc
ml/main.cc

index f4dc7a4..57372d2 100644 (file)
--- a/config.h
+++ b/config.h
@@ -7,11 +7,11 @@
 //#define  kErrorLog           cDataTop "/logs/error_log"
 #define  cDEFAULTTIMELIMIT     300
 #define  cLOGSHORTSIZE         500
-#define  cPOSTLIMITDEFAULT     (1024*1024)
-#define  cPOSTLIMITHARD                (10*1024*1024)
-#define  cPOSTFILELIMITDEFAULT (3*1024*1024)
-#define  cPOSTFILELIMITHARD    (500*1024*1024)
-#define  cResourceFileMax      (1024*1024)
+#define  cPOSTLIMITDEFAULT     (1LL*1024*1024)
+#define  cPOSTLIMITHARD                (10LL*1024*1024)
+#define  cPOSTFILELIMITDEFAULT (3LL*1024*1024)
+#define  cPOSTFILELIMITHARD    (500LL*1024*1024)
+#define  cResourceFileMax      (5LL*1024*1024)
 #define  cmd_qmailinject       "/var/qmail/bin/qmail-inject"
 #define  cmd_rm                        "/bin/rm"
 #define  path_devnull          "/dev/null"
@@ -30,5 +30,6 @@
 //#define  HTTPS_NOCACHE       1
 //#define  QUERYENCODEALT              1
 #define  STANDALONE            1
+#define FreeBSDPortsIConv      1
 
 #endif /* CONFIG_H */
index 046ead7..1fe01a8 100644 (file)
@@ -108,10 +108,8 @@ void  AppEnv::readOption (int argc, char** argv, MotorEnv* env) {
            if (! matchName (ocode))
                throw (ocode + ": bad encoding name.");
        } else if (cmp (p, "post-limit:")) {
-           int  num = boost::lexical_cast <int> (p);
-           if (num < 0) {
-               postlimit = cPOSTLIMITDEFAULT;
-           } else if (num > cPOSTLIMITHARD) {
+           size_t  num = boost::lexical_cast <size_t> (p);
+           if (num > cPOSTLIMITHARD) {
                *env->log << "post-limit:" << num << ": limit exceeded.\n";
                postlimit = cPOSTLIMITHARD;
            } else {
@@ -119,10 +117,8 @@ void  AppEnv::readOption (int argc, char** argv, MotorEnv* env) {
            }
        } else if (cmp (p, "postfile-limit:")
                   || cmp (p, "post-file-limit:")) {
-           int  num = boost::lexical_cast <int> (p);
-           if (num < 0) {
-               postfilelimit = cPOSTFILELIMITDEFAULT;
-           } else if (num > cPOSTFILELIMITHARD) {
+           size_t  num = boost::lexical_cast <size_t> (p);
+           if (num > cPOSTFILELIMITHARD) {
                *env->log << "post-file-limit:" << num << ": limit exceeded.\n";
                postfilelimit = cPOSTFILELIMITHARD;
            } else {
index 8c782d7..7dfe8c7 100644 (file)
@@ -52,7 +52,7 @@ void  CGIFormFile::read_multipart (MotorEnv* env) {
 }
 
 bool  CGIFormFile::saveData (MotorEnv* env) {
-    static const int  bsize = 65536 * 4;
+    static const size_t  bsize = 65536 * 4;
     size_t  size = postSize ();
     ustring  b;
     size_t  s;
@@ -257,10 +257,8 @@ class  ChSplitterNL {
 };
 
 void  CGIFormFile::readMimeHead (char*& b, char* e, ustring& disp, ustring& name, ustring& filename, ustring& type) {
-//    boost::match_results<char*>  m;
     ChSplitterNL  sp (b, e);
     boost::match_results<char*>  m2;
-//    char*  x;
     static uregex  re_disp1 ("^Content-Disposition:\\s*(.*);\\s*name=\"(.*)\";\\s*filename=\"(.*)\"$");
     static uregex  re_disp2 ("^Content-Disposition:\\s*(.*);\\s*name=\"(.*)\"$");
     static uregex  re_type ("^Content-Type:\\s*([a-zA-Z_0-9/.+-]*)(;\\s*(.*))?$");
@@ -269,38 +267,28 @@ void  CGIFormFile::readMimeHead (char*& b, char* e, ustring& disp, ustring& name
     name.resize (0);
     filename.resize (0);
     type.resize (0);
-//    while (b != e && regex_search (b, e, m, re_nl, boost::regex_constants::match_single_line)) {
-//     x = m[0].first;
     while (sp.next ()) {
 #ifdef DEBUG2
-//     std::cerr << "line:" << ustring (b, x) << "\n";
        std::cerr << "line:" << sp.pre () << "\n";
 #endif /* DEBUG */
-//     if (b == x) {           // empty line
-//         b = m[0].second;
        if (sp.b == sp.t) {
            b = sp.u;
            break;
        }
-//     if (regex_search (b, x, m2, re_disp1, boost::regex_constants::match_single_line)) {
        if (regex_search (sp.b, sp.t, m2, re_disp1, boost::regex_constants::match_single_line)) {
            disp.assign (m2[1].first, m2[1].second - m2[1].first);
            name.assign (m2[2].first, m2[2].second - m2[2].first);
            filename.assign (m2[3].first, m2[3].second - m2[3].first);
-//     } else if (regex_search (b, x, m2, re_disp2, boost::regex_constants::match_single_line)) {
        } else if (regex_search (sp.b, sp.t, m2, re_disp2, boost::regex_constants::match_single_line)) {
            disp.assign (m2[1].first, m2[1].second - m2[1].first);
            name.assign (m2[2].first, m2[2].second - m2[2].first);
-//     } else if (regex_search (b, x, m2, re_type, boost::regex_constants::match_single_line)) {
        } else if (regex_search (sp.b, sp.t, m2, re_type, boost::regex_constants::match_single_line)) {
            type.assign (m2[1].first, m2[1].second - m2[1].first);
        } else {
 #ifdef DEBUG2
-//         std::cerr << "not match:" << ustring (b, x) << "\n";
            std::cerr << "not match:" << sp.pre () << "\n";
 #endif /* DEBUG */
        }
-//     b = m[0].second;
     }
 }
 
index 71ed87e..81f536c 100644 (file)
@@ -90,6 +90,10 @@ int  main (int argc, char** argv) {
        std::cerr << msg << "\n";
        goto Ex1;
     }
+    catch (boost::bad_lexical_cast msg) {
+       std::cerr << "bad values\n";
+       goto Ex1;
+    }
 
  Ex1:;
     delete out;