Guest User

Untitled

a guest
Nov 13th, 2015
240
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.69 KB | None | 0 0
  1. ? httpd
  2. ? httpd_url_rewrite.patch
  3. ? parse.c
  4. ? y.tab.h
  5. Index: parse.y
  6. ===================================================================
  7. RCS file: /cvs/src/usr.sbin/httpd/parse.y,v
  8. retrieving revision 1.73
  9. diff -u -p -u -r1.73 parse.y
  10. --- parse.y 19 Jul 2015 05:17:27 -0000 1.73
  11. +++ parse.y 13 Nov 2015 08:29:10 -0000
  12. @@ -907,7 +907,7 @@ filter : block RETURN NUMBER optstring
  13.  
  14. if ($4 != NULL) {
  15. /* Only for 3xx redirection headers */
  16. - if ($3 < 300 || $3 > 399) {
  17. + if ($3 != 200 && ($3 < 300 || $3 > 399)) {
  18. yyerror("invalid return code for "
  19. "location URI");
  20. free($4);
  21. Index: server_http.c
  22. ===================================================================
  23. RCS file: /cvs/src/usr.sbin/httpd/server_http.c,v
  24. retrieving revision 1.96
  25. diff -u -p -u -r1.96 server_http.c
  26. --- server_http.c 31 Jul 2015 00:10:51 -0000 1.96
  27. +++ server_http.c 13 Nov 2015 08:29:10 -0000
  28. @@ -1054,6 +1054,7 @@ server_response(struct httpd *httpd, str
  29. int portval = -1, ret;
  30. char *hostval;
  31. const char *errstr = NULL;
  32. + char buf[IBUF_READ_SIZE];
  33.  
  34. /* Canonicalize the request path */
  35. if (desc->http_path == NULL ||
  36. @@ -1154,11 +1155,44 @@ server_response(struct httpd *httpd, str
  37. resp->http_method = desc->http_method;
  38. if ((resp->http_version = strdup(desc->http_version)) == NULL)
  39. goto fail;
  40. +
  41. +#ifdef DEBUG
  42. + DPRINTF("%s: http_path: %s, http_path_alias: %s\n", __func__, desc->http_path, desc->http_path_alias);
  43. +#endif
  44.  
  45. /* Now search for the location */
  46. srv_conf = server_getlocation(clt, desc->http_path);
  47.  
  48. - if (srv_conf->flags & SRVFLAG_BLOCK) {
  49. +
  50. + if ((srv_conf->flags & SRVFLAG_BLOCK) && srv_conf->return_code == 200) {
  51. +#ifdef DEBUG
  52. + DPRINTF("%s: Rewrite from: %s to %s\n", __func__, desc->http_path, srv_conf->return_uri);
  53. +#endif
  54. + if (desc->http_path != NULL) {
  55. + free(desc->http_path);
  56. + desc->http_path = NULL;
  57. + }
  58. + if (server_expand_http(clt, srv_conf->return_uri, buf, sizeof(buf)) == NULL) {
  59. + server_abort_http(clt, 500, strerror(errno));
  60. + return (-1);
  61. + }
  62. + desc->http_path = strdup(buf);
  63. + if (desc->http_path == NULL) {
  64. + server_abort_http(clt, 500, strerror(errno));
  65. + }
  66. + desc->http_query = strchr(desc->http_path, '?');
  67. + if (desc->http_query != NULL) {
  68. + *desc->http_query++ = '\0';
  69. + desc->http_query = strdup(desc->http_query);
  70. + if (desc->http_query == NULL) {
  71. + server_abort_http(clt, 500, strerror(errno));
  72. + }
  73. + }
  74. + srv_conf = server_getlocation(clt, desc->http_path); // again
  75. + }
  76. +
  77. +
  78. + if ((srv_conf->flags & SRVFLAG_BLOCK) && srv_conf->return_code != 200) {
  79. server_abort_http(clt, srv_conf->return_code,
  80. srv_conf->return_uri);
  81. return (-1);
Advertisement
Add Comment
Please, Sign In to add comment