~ubuntu-branches/ubuntu/lucid/monit/lucid

« back to all changes in this revision

Viewing changes to http/processor.c

  • Committer: Bazaar Package Importer
  • Author(s): Stefan Alfredsson
  • Date: 2009-08-18 22:49:13 UTC
  • mfrom: (1.1.5 upstream)
  • Revision ID: james.westby@ubuntu.com-20090818224913-6z5wghd0qfiuy7fh
Tags: 1:5.0.3-3
* Daemon poll interval moved to rc-file instead of defaults
  (Closes: #541425)
* Package upgraded (Closes: 453248)
* Configuration snippets are included from /etc/monit/conf.d/*
  (Closes: #296479)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
 
 * Copyright (C), 2000-2007 by the monit project group.
3
 
 * All Rights Reserved.
 
2
 * Copyright (C) 2009 Tildeslash Ltd. All rights reserved.
4
3
 *
5
4
 * This program is free software: you can redistribute it and/or modify
6
 
 * it under the terms of the GNU General Public License as published by
7
 
 * the Free Software Foundation, either version 3 of the License, or
8
 
 * (at your option) any later version.
 
5
 * it under the terms of the GNU General Public License version 3.
9
6
 *
10
7
 * This program is distributed in the hope that it will be useful,
11
8
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
11
 *
15
12
 * You should have received a copy of the GNU General Public License
16
13
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
14
 *
 
15
 * In addition, as a special exception, the copyright holders give
 
16
 * permission to link the code of portions of this program with the
 
17
 * OpenSSL library under certain conditions as described in each
 
18
 * individual source file, and distribute linked combinations
 
19
 * including the two.
 
20
 *
 
21
 * You must obey the GNU General Public License in all respects
 
22
 * for all of the code used other than OpenSSL.  If you modify
 
23
 * file(s) with this exception, you may extend this exception to your
 
24
 * version of the file(s), but you are not obligated to do so.  If you
 
25
 * do not wish to do so, delete this exception statement from your
 
26
 * version.  If you delete this exception statement from all source
 
27
 * files in the program, then also delete it here.
17
28
 */
18
29
 
19
30
#include <config.h>
100
111
 *  @author Jan-Henrik Haukeland, <hauk@tildeslash.com>
101
112
 *  @author Christian Hopp, <chopp@iei.tu-clausthal.de>
102
113
 *
103
 
 *  @version \$Id: processor.c,v 1.61 2007/10/11 20:48:06 martinp Exp $
 
114
 *  @version \$Id: processor.c,v 1.73 2009/05/09 15:11:39 martinp Exp $
104
115
 *
105
116
 *  @file
106
117
 */
181
192
           "<hr><a href='%s'><font size=-1>%s</font></a>"\
182
193
           "</body></html>\r\n",
183
194
            code, err, err, msg?msg:"", SERVER_URL, get_server(server, STRLEN));
 
195
        DEBUG("HttpRequest error: %s %d %s\n", SERVER_PROTOCOL, code, msg ? msg : err);
184
196
}
185
197
 
186
198
 
529
541
    return NULL;
530
542
  }
531
543
  Util_chomp(line);
532
 
  if(sscanf(line, "%s %s HTTP/%3[1.0]", method, url, protocol) != 3) {
 
544
  if(sscanf(line, "%1023s %1023s HTTP/%3[1.0]", method, url, protocol) != 3) {
533
545
    internal_error(S, SC_BAD_REQUEST, "Cannot parse request");
534
546
    return NULL;
535
547
  }
545
557
  req->protocol= xstrdup(protocol); 
546
558
  create_headers(req);
547
559
  if(!create_parameters(req)) {
 
560
    destroy_HttpRequest(req);
548
561
    internal_error(S, SC_BAD_REQUEST, "Cannot parse Request parameters");
549
 
    destroy_HttpRequest(req);
550
562
    return NULL;
551
563
  }
552
564
  return req;
613
625
  if(IS(req->method, METHOD_POST) && get_header(req, "Content-Length")) {
614
626
    int n;
615
627
    int len; 
616
 
    Socket_T S= req->S;
617
 
    if(1 != sscanf(get_header(req, "Content-Length"), "%d", &len)) {
 
628
    Socket_T S = req->S;
 
629
    const char *cl = get_header(req, "Content-Length");
 
630
    if(! cl || sscanf(cl, "%d", &len) != 1) {
618
631
      return FALSE;
619
632
    }
620
633
    if(len < 0 || len >= REQ_STRLEN)
629
642
    char *p;
630
643
    if(NULL != (p= strchr(req->url, '?'))) {
631
644
      *p++= 0;
632
 
      strncpy(query_string, p, REQ_STRLEN);
 
645
      strncpy(query_string, p, sizeof(query_string) - 1);
 
646
      query_string[sizeof(query_string) - 1] = 0;
633
647
    }
634
648
  }
635
649
  if(*query_string) {
752
766
  if(! (credentials && Util_startsWith(credentials, "Basic "))) {
753
767
    return FALSE;
754
768
  }
755
 
  strncpy(buf, &credentials[6], STRLEN);
 
769
  strncpy(buf, &credentials[6], sizeof(buf) - 1);
 
770
  buf[sizeof(buf) - 1] = 0;
756
771
  if((n= decode_base64((unsigned char*)uname, buf))<=0) {
757
772
    return FALSE;
758
773
  }
810
825
               "</body></html>\r\n",
811
826
               SERVER_PROTOCOL, status, status_msg, date, server,
812
827
               status_msg, status_msg, msg, SERVER_URL, server);
 
828
  DEBUG("HttpRequest error: %s %d %s\n", SERVER_PROTOCOL, status, msg ? msg : status_msg);
813
829
}
814
830
 
815
831