Skip to content
This repository
Browse code

Merge branch 'release/1.0.0'

  • Loading branch information...
commit b923e2384ff80ff0b288fe8239d227f8af3a8c05 2 parents 7ef5117 + 4bbda88
Mark Ellzey authored August 15, 2012
7  ChangeLog
... ...
@@ -1,3 +1,10 @@
  1
+v1.0.0
  2
+ o Added some function documentation. (adc3ac6 Mark Ellzey)
  3
+ o Check for null deref on request check. (a722fc4 Mark Ellzey)
  4
+ o Fix for state set override for headers. (87fb859 Mark Ellzey)
  5
+ o No need for null checks before free(). (7783ca2 Mark Ellzey)
  6
+ o Bumping this up to 1.0.0 since it's been in production for a while.
  7
+
1 8
 v0.4.17
2 9
  o Added cmake option for disabling regex. (5ab2e4b Mark Ellzey)
3 10
  o Cleanup compiler warnings. (770a344 Mark Ellzey)
94  evhtp.c
@@ -766,9 +766,6 @@ _evhtp_request_free(evhtp_request_t * request) {
766 766
     evhtp_headers_free(request->headers_in);
767 767
     evhtp_headers_free(request->headers_out);
768 768
 
769  
-    if (request->hooks) {
770  
-        free(request->hooks);
771  
-    }
772 769
 
773 770
     if (request->buffer_in) {
774 771
         evbuffer_free(request->buffer_in);
@@ -778,7 +775,7 @@ _evhtp_request_free(evhtp_request_t * request) {
778 775
         evbuffer_free(request->buffer_out);
779 776
     }
780 777
 
781  
-
  778
+    free(request->hooks);
782 779
     free(request);
783 780
 }
784 781
 
@@ -812,14 +809,8 @@ _evhtp_uri_free(evhtp_uri_t * uri) {
812 809
     evhtp_query_free(uri->query);
813 810
     _evhtp_path_free(uri->path);
814 811
 
815  
-    if (uri->fragment) {
816  
-        free(uri->fragment);
817  
-    }
818  
-
819  
-    if (uri->query_raw) {
820  
-        free(uri->query_raw);
821  
-    }
822  
-
  812
+    free(uri->fragment);
  813
+    free(uri->query_raw);
823 814
     free(uri);
824 815
 }
825 816
 
@@ -931,25 +922,12 @@ _evhtp_path_free(evhtp_path_t * path) {
931 922
         return;
932 923
     }
933 924
 
934  
-    if (path->full) {
935  
-        free(path->full);
936  
-    }
  925
+    free(path->full);
937 926
 
938  
-    if (path->path) {
939  
-        free(path->path);
940  
-    }
941  
-
942  
-    if (path->file) {
943  
-        free(path->file);
944  
-    }
945  
-
946  
-    if (path->match_start) {
947  
-        free(path->match_start);
948  
-    }
949  
-
950  
-    if (path->match_end) {
951  
-        free(path->match_end);
952  
-    }
  927
+    free(path->path);
  928
+    free(path->file);
  929
+    free(path->match_start);
  930
+    free(path->match_end);
953 931
 
954 932
     free(path);
955 933
 }
@@ -1344,7 +1322,13 @@ _evhtp_request_parser_fini(htparser * p) {
1344 1322
 
1345 1323
     /* c->request->finished = 1; */
1346 1324
 
1347  
-    if (c->request->cb) {
  1325
+    /*
  1326
+     * XXX c->request should never be NULL, but we have found some path of
  1327
+     * execution where this actually happens. We will check for now, but the bug
  1328
+     * path needs to be tracked down.
  1329
+     *
  1330
+     */
  1331
+    if (c->request && c->request->cb) {
1348 1332
         (c->request->cb)(c->request, c->request->cbarg);
1349 1333
     }
1350 1334
 
@@ -2010,11 +1994,11 @@ evhtp_kv_free(evhtp_kv_t * kv) {
2010 1994
         return;
2011 1995
     }
2012 1996
 
2013  
-    if (kv->k_heaped && kv->key) {
  1997
+    if (kv->k_heaped) {
2014 1998
         free(kv->key);
2015 1999
     }
2016 2000
 
2017  
-    if (kv->v_heaped && kv->val) {
  2001
+    if (kv->v_heaped) {
2018 2002
         free(kv->val);
2019 2003
     }
2020 2004
 
@@ -2398,23 +2382,13 @@ evhtp_parse_query(const char * query, size_t len) {
2398 2382
         evhtp_kvs_add_kv(query_args, evhtp_kv_new(key_buf, val_buf, 1, 1));
2399 2383
     }
2400 2384
 
2401  
-    if (key_buf) {
2402  
-        free(key_buf);
2403  
-    }
2404  
-
2405  
-    if (val_buf) {
2406  
-        free(val_buf);
2407  
-    }
  2385
+    free(key_buf);
  2386
+    free(val_buf);
2408 2387
 
2409 2388
     return query_args;
2410 2389
 error:
2411  
-    if (key_buf) {
2412  
-        free(key_buf);
2413  
-    }
2414  
-
2415  
-    if (val_buf) {
2416  
-        free(val_buf);
2417  
-    }
  2390
+    free(key_buf);
  2391
+    free(val_buf);
2418 2392
 
2419 2393
     return NULL;
2420 2394
 }     /* evhtp_parse_query */
@@ -2772,20 +2746,14 @@ evhtp_callback_free(evhtp_callback_t * callback) {
2772 2746
 
2773 2747
     switch (callback->type) {
2774 2748
         case evhtp_callback_type_hash:
2775  
-            if (callback->val.path) {
2776  
-                free(callback->val.path);
2777  
-            }
  2749
+            free(callback->val.path);
2778 2750
             break;
2779 2751
         case evhtp_callback_type_glob:
2780  
-            if (callback->val.glob) {
2781  
-                free(callback->val.glob);
2782  
-            }
  2752
+            free(callback->val.glob);
2783 2753
             break;
2784 2754
 #ifndef EVHTP_DISABLE_REGEX
2785 2755
         case evhtp_callback_type_regex:
2786  
-            if (callback->val.regex) {
2787  
-                regfree(callback->val.regex);
2788  
-            }
  2756
+            regfree(callback->val.regex);
2789 2757
             break;
2790 2758
 #endif
2791 2759
     }
@@ -3331,9 +3299,9 @@ evhtp_connection_free(evhtp_connection_t * connection) {
3331 3299
     _evhtp_request_free(connection->request);
3332 3300
     _evhtp_connection_fini_hook(connection);
3333 3301
 
3334  
-    if (connection->parser) {
3335  
-        free(connection->parser);
3336  
-    }
  3302
+    free(connection->parser);
  3303
+    free(connection->hooks);
  3304
+    free(connection->saddr);
3337 3305
 
3338 3306
     if (connection->resume_ev) {
3339 3307
         event_free(connection->resume_ev);
@@ -3353,20 +3321,12 @@ evhtp_connection_free(evhtp_connection_t * connection) {
3353 3321
 #endif
3354 3322
     }
3355 3323
 
3356  
-    if (connection->hooks) {
3357  
-        free(connection->hooks);
3358  
-    }
3359  
-
3360 3324
 #ifndef EVHTP_DISABLE_EVTHR
3361 3325
     if (connection->thread) {
3362 3326
         evthr_dec_backlog(connection->thread);
3363 3327
     }
3364 3328
 #endif
3365 3329
 
3366  
-    if (connection->saddr) {
3367  
-        free(connection->saddr);
3368  
-    }
3369  
-
3370 3330
     free(connection);
3371 3331
 }     /* evhtp_connection_free */
3372 3332
 
104  evhtp.h
@@ -155,10 +155,10 @@ typedef void (*evhtp_ssl_scache_del)(evhtp_t * htp, unsigned char * sid, int sid
155 155
 typedef evhtp_ssl_sess_t * (*evhtp_ssl_scache_get)(evhtp_connection_t * connection, unsigned char * sid, int sid_len);
156 156
 typedef void * (*evhtp_ssl_scache_init)(evhtp_t *);
157 157
 
158  
-#define EVHTP_VERSION          "0.4.17"
159  
-#define EVHTP_VERSION_MAJOR    0
160  
-#define EVHTP_VERSION_MINOR    4
161  
-#define EVHTP_VERSION_PATCH    17
  158
+#define EVHTP_VERSION          "1.0.0"
  159
+#define EVHTP_VERSION_MAJOR    1
  160
+#define EVHTP_VERSION_MINOR    0
  161
+#define EVHTP_VERSION_PATCH    0
162 162
 
163 163
 #define evhtp_headers_iterator evhtp_kvs_iterator
164 164
 
@@ -504,10 +504,10 @@ evhtp_t * evhtp_new(evbase_t * evbase, void * arg);
504 504
  * @param r read-timeout in timeval
505 505
  * @param w write-timeout in timeval.
506 506
  */
507  
-void      evhtp_set_timeouts(evhtp_t * htp, struct timeval * r, struct timeval * w);
508  
-void      evhtp_set_bev_flags(evhtp_t * htp, int flags);
509  
-int       evhtp_ssl_use_threads(void);
510  
-int       evhtp_ssl_init(evhtp_t * htp, evhtp_ssl_cfg_t * ssl_cfg);
  507
+void evhtp_set_timeouts(evhtp_t * htp, struct timeval * r, struct timeval * w);
  508
+void evhtp_set_bev_flags(evhtp_t * htp, int flags);
  509
+int  evhtp_ssl_use_threads(void);
  510
+int  evhtp_ssl_init(evhtp_t * htp, evhtp_ssl_cfg_t * ssl_cfg);
511 511
 
512 512
 
513 513
 /**
@@ -635,16 +635,42 @@ int evhtp_unset_hook(evhtp_hooks_t ** hooks, evhtp_hook_type type);
635 635
  *
636 636
  * @return
637 637
  */
638  
-int  evhtp_unset_all_hooks(evhtp_hooks_t ** hooks);
  638
+int evhtp_unset_all_hooks(evhtp_hooks_t ** hooks);
639 639
 
640  
-int  evhtp_bind_socket(evhtp_t * htp, const char * addr, uint16_t port, int backlog);
  640
+
  641
+/**
  642
+ * @brief bind to a socket, optionally with specific protocol support
  643
+ *        formatting. The addr can be defined as one of the following:
  644
+ *          ipv6:<ipv6addr> for binding to an IPv6 address.
  645
+ *          unix:<named pipe> for binding to a unix named socket
  646
+ *          ipv4:<ipv4addr> for binding to an ipv4 address
  647
+ *        Otherwise the addr is assumed to be ipv4.
  648
+ *
  649
+ * @param htp
  650
+ * @param addr
  651
+ * @param port
  652
+ * @param backlog
  653
+ *
  654
+ * @return
  655
+ */
  656
+int evhtp_bind_socket(evhtp_t * htp, const char * addr, uint16_t port, int backlog);
  657
+
  658
+
  659
+/**
  660
+ * @brief bind to an already allocated sockaddr.
  661
+ *
  662
+ * @param htp
  663
+ * @param
  664
+ * @param sin_len
  665
+ * @param backlog
  666
+ *
  667
+ * @return
  668
+ */
641 669
 int  evhtp_bind_sockaddr(evhtp_t * htp, struct sockaddr *, size_t sin_len, int backlog);
642 670
 void evhtp_unbind_socket(evhtp_t * htp, int deinit_status_codes);
643 671
 
644 672
 int  evhtp_use_threads(evhtp_t * htp, evhtp_thread_init_cb init_cb, int nthreads, void * arg);
645  
-
646 673
 void evhtp_send_reply(evhtp_request_t * request, evhtp_res code);
647  
-
648 674
 void evhtp_send_reply_start(evhtp_request_t * request, evhtp_res code);
649 675
 void evhtp_send_reply_body(evhtp_request_t * request, evbuf_t * buf);
650 676
 void evhtp_send_reply_end(evhtp_request_t * request);
@@ -655,9 +681,34 @@ void evhtp_send_reply_end(evhtp_request_t * request);
655 681
  * @return 1 if the response MUST have a body; 0 if the response MUST NOT have
656 682
  *     a body.
657 683
  */
658  
-int  evhtp_response_needs_body(const evhtp_res code, const htp_method method);
  684
+int evhtp_response_needs_body(const evhtp_res code, const htp_method method);
  685
+
  686
+
  687
+/**
  688
+ * @brief start a chunked response. If data already exists on the output buffer,
  689
+ *        this will be converted to the first chunk.
  690
+ *
  691
+ * @param request
  692
+ * @param code
  693
+ */
659 694
 void evhtp_send_reply_chunk_start(evhtp_request_t * request, evhtp_res code);
  695
+
  696
+
  697
+/**
  698
+ * @brief send a chunk reply.
  699
+ *
  700
+ * @param request
  701
+ * @param buf
  702
+ */
660 703
 void evhtp_send_reply_chunk(evhtp_request_t * request, evbuf_t * buf);
  704
+
  705
+
  706
+/**
  707
+ * @brief call when all chunks have been sent and you wish to send the last
  708
+ *        bits. This will add the last 0CRLFCRCL and call send_reply_end().
  709
+ *
  710
+ * @param request
  711
+ */
661 712
 void evhtp_send_reply_chunk_end(evhtp_request_t * request);
662 713
 
663 714
 
@@ -709,9 +760,34 @@ void               evhtp_callback_free(evhtp_callback_t * callback);
709 760
  */
710 761
 int evhtp_callbacks_add_callback(evhtp_callbacks_t * cbs, evhtp_callback_t * cb);
711 762
 
712  
-int evhtp_add_alias(evhtp_t * evhtp, const char * name);
  763
+
  764
+/**
  765
+ * @brief add an evhtp_t structure (with its own callbacks) to a base evhtp_t
  766
+ *        structure for virtual hosts. It should be noted that if you enable SSL
  767
+ *        on the base evhtp_t and your version of OpenSSL supports SNI, the SNI
  768
+ *        hostname will always take precedence over the Host header value.
  769
+ *
  770
+ * @param evhtp
  771
+ * @param name
  772
+ * @param vhost
  773
+ *
  774
+ * @return
  775
+ */
713 776
 int evhtp_add_vhost(evhtp_t * evhtp, const char * name, evhtp_t * vhost);
714 777
 
  778
+
  779
+/**
  780
+ * @brief Add an alias hostname for a virtual-host specific evhtp_t. This avoids
  781
+ *        having multiple evhtp_t virtual hosts with the same callback for the same
  782
+ *        vhost.
  783
+ *
  784
+ * @param evhtp
  785
+ * @param name
  786
+ *
  787
+ * @return
  788
+ */
  789
+int evhtp_add_alias(evhtp_t * evhtp, const char * name);
  790
+
715 791
 /**
716 792
  * @brief Allocates a new key/value structure.
717 793
  *
4  htparse/htparse.c
@@ -1482,10 +1482,10 @@ htparser_run(htparser * p, htparse_hooks * hooks, const char * data, size_t len)
1482 1482
                         } else if (p->content_len == 0) {
1483 1483
                             res      = hook_on_msg_complete_run(p, hooks);
1484 1484
                             p->state = s_start;
  1485
+                        } else {
  1486
+                            p->state = s_hdrline_done;
1485 1487
                         }
1486 1488
 
1487  
-                        p->state = s_hdrline_done;
1488  
-
1489 1489
                         if (res) {
1490 1490
                             p->error = htparse_error_user;
1491 1491
                             return i + 1;

0 notes on commit b923e23

Please sign in to comment.
Something went wrong with that request. Please try again.