patch-libhttpd_api_c 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  1. $Id: update-patches 24 2008-08-31 14:56:13Z wbx $
  2. --- wifidog-1.1.5.orig/libhttpd/api.c 2007-11-01 21:04:20.000000000 +0100
  3. +++ wifidog-1.1.5/libhttpd/api.c 2014-01-01 16:20:22.000000000 +0100
  4. @@ -166,7 +166,7 @@ int httpdAddVariable(request *r, char *n
  5. while(*name == ' ' || *name == '\t')
  6. name++;
  7. newVar = malloc(sizeof(httpVar));
  8. - bzero(newVar, sizeof(httpVar));
  9. + memset(newVar, 0, sizeof(httpVar));
  10. newVar->name = strdup(name);
  11. newVar->value = strdup(value);
  12. lastVar = NULL;
  13. @@ -209,14 +209,14 @@ httpd *httpdCreate(host, port)
  14. new = malloc(sizeof(httpd));
  15. if (new == NULL)
  16. return(NULL);
  17. - bzero(new, sizeof(httpd));
  18. + memset(new, 0, sizeof(httpd));
  19. new->port = port;
  20. if (host == HTTP_ANY_ADDR)
  21. new->host = HTTP_ANY_ADDR;
  22. else
  23. new->host = strdup(host);
  24. new->content = (httpDir*)malloc(sizeof(httpDir));
  25. - bzero(new->content,sizeof(httpDir));
  26. + memset(new->content, 0, sizeof(httpDir));
  27. new->content->name = strdup("");
  28. /*
  29. @@ -270,7 +270,7 @@ httpd *httpdCreate(host, port)
  30. setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (char*)&opt,sizeof(int));
  31. # endif
  32. new->serverSock = sock;
  33. - bzero(&addr, sizeof(addr));
  34. + memset(&addr, 0, sizeof(addr));
  35. addr.sin_family = AF_INET;
  36. if (new->host == HTTP_ANY_ADDR)
  37. {
  38. @@ -344,7 +344,7 @@ request *httpdGetConnection(server, time
  39. }
  40. memset((void *)r, 0, sizeof(request));
  41. /* Get on with it */
  42. - bzero(&addr, sizeof(addr));
  43. + memset(&addr, 0, sizeof(addr));
  44. addrLen = sizeof(addr);
  45. r->clientSock = accept(server->serverSock,(struct sockaddr *)&addr,
  46. &addrLen);
  47. @@ -469,14 +469,14 @@ int httpdReadRequest(httpd *server, requ
  48. *val,
  49. *end;
  50. - var = index(buf,':');
  51. + var = strchr(buf,':');
  52. while(var)
  53. {
  54. var++;
  55. - val = index(var, '=');
  56. + val = strchr(var, '=');
  57. *val = 0;
  58. val++;
  59. - end = index(val,';');
  60. + end = strchr(val,';');
  61. if(end)
  62. *end = 0;
  63. httpdAddVariable(r, var, val);
  64. @@ -488,7 +488,7 @@ int httpdReadRequest(httpd *server, requ
  65. #if 0
  66. if (strncasecmp(buf,"Authorization: ",15) == 0)
  67. {
  68. - cp = index(buf,':') + 2;
  69. + cp = strchr(buf,':') + 2;
  70. if (strncmp(cp,"Basic ", 6) != 0)
  71. {
  72. /* Unknown auth method */
  73. @@ -497,11 +497,11 @@ int httpdReadRequest(httpd *server, requ
  74. {
  75. char authBuf[100];
  76. - cp = index(cp,' ') + 1;
  77. + cp = strchr(cp,' ') + 1;
  78. _httpd_decode(cp, authBuf, 100);
  79. r->request.authLength =
  80. strlen(authBuf);
  81. - cp = index(authBuf,':');
  82. + cp = strchr(authBuf,':');
  83. if (cp)
  84. {
  85. *cp = 0;
  86. @@ -517,7 +517,7 @@ int httpdReadRequest(httpd *server, requ
  87. #if 0
  88. if (strncasecmp(buf,"Referer: ",9) == 0)
  89. {
  90. - cp = index(buf,':') + 2;
  91. + cp = strchr(buf,':') + 2;
  92. if(cp)
  93. {
  94. strncpy(r->request.referer,cp,
  95. @@ -529,7 +529,7 @@ int httpdReadRequest(httpd *server, requ
  96. * present. */
  97. if (strncasecmp(buf,"Host: ",6) == 0)
  98. {
  99. - cp = index(buf,':') + 2;
  100. + cp = strchr(buf,':') + 2;
  101. if(cp)
  102. {
  103. strncpy(r->request.host,cp,
  104. @@ -540,12 +540,12 @@ int httpdReadRequest(httpd *server, requ
  105. #if 0
  106. if (strncasecmp(buf,"If-Modified-Since: ",19) == 0)
  107. {
  108. - cp = index(buf,':') + 2;
  109. + cp = strchr(buf,':') + 2;
  110. if(cp)
  111. {
  112. strncpy(r->request.ifModified,cp,
  113. HTTP_MAX_URL);
  114. - cp = index(r->request.ifModified,
  115. + cp = strchr(r->request.ifModified,
  116. ';');
  117. if (cp)
  118. *cp = 0;
  119. @@ -553,7 +553,7 @@ int httpdReadRequest(httpd *server, requ
  120. }
  121. if (strncasecmp(buf,"Content-Type: ",14) == 0)
  122. {
  123. - cp = index(buf,':') + 2;
  124. + cp = strchr(buf,':') + 2;
  125. if(cp)
  126. {
  127. strncpy(r->request.contentType,cp,
  128. @@ -562,7 +562,7 @@ int httpdReadRequest(httpd *server, requ
  129. }
  130. if (strncasecmp(buf,"Content-Length: ",16) == 0)
  131. {
  132. - cp = index(buf,':') + 2;
  133. + cp = strchr(buf,':') + 2;
  134. if(cp)
  135. r->request.contentLength=atoi(cp);
  136. }
  137. @@ -581,7 +581,7 @@ int httpdReadRequest(httpd *server, requ
  138. */
  139. if (r->request.contentLength > 0)
  140. {
  141. - bzero(buf, HTTP_MAX_LEN);
  142. + memset(buf, 0, HTTP_MAX_LEN);
  143. _httpd_readBuf(r, buf, r->request.contentLength);
  144. _httpd_storeData(r, buf);
  145. @@ -591,7 +591,7 @@ int httpdReadRequest(httpd *server, requ
  146. /*
  147. ** Process any URL data
  148. */
  149. - cp = index(r->request.path,'?');
  150. + cp = strchr(r->request.path,'?');
  151. if (cp != NULL)
  152. {
  153. *cp++ = 0;
  154. @@ -661,7 +661,7 @@ int httpdAddFileContent(server, dir, nam
  155. newEntry = malloc(sizeof(httpContent));
  156. if (newEntry == NULL)
  157. return(-1);
  158. - bzero(newEntry,sizeof(httpContent));
  159. + memset(newEntry, 0, sizeof(httpContent));
  160. newEntry->name = strdup(name);
  161. newEntry->type = HTTP_FILE;
  162. newEntry->indexFlag = indexFlag;
  163. @@ -699,7 +699,7 @@ int httpdAddWildcardContent(server, dir,
  164. newEntry = malloc(sizeof(httpContent));
  165. if (newEntry == NULL)
  166. return(-1);
  167. - bzero(newEntry,sizeof(httpContent));
  168. + memset(newEntry, 0, sizeof(httpContent));
  169. newEntry->name = NULL;
  170. newEntry->type = HTTP_WILDCARD;
  171. newEntry->indexFlag = HTTP_FALSE;
  172. @@ -755,7 +755,7 @@ int httpdAddCContent(server, dir, name,
  173. newEntry = malloc(sizeof(httpContent));
  174. if (newEntry == NULL)
  175. return(-1);
  176. - bzero(newEntry,sizeof(httpContent));
  177. + memset(newEntry, 0, sizeof(httpContent));
  178. newEntry->name = strdup(name);
  179. newEntry->type = HTTP_C_FUNCT;
  180. newEntry->indexFlag = indexFlag;
  181. @@ -780,7 +780,7 @@ int httpdAddCWildcardContent(server, dir
  182. newEntry = malloc(sizeof(httpContent));
  183. if (newEntry == NULL)
  184. return(-1);
  185. - bzero(newEntry,sizeof(httpContent));
  186. + memset(newEntry, 0, sizeof(httpContent));
  187. newEntry->name = NULL;
  188. newEntry->type = HTTP_C_WILDCARD;
  189. newEntry->indexFlag = HTTP_FALSE;
  190. @@ -805,7 +805,7 @@ int httpdAddStaticContent(server, dir, n
  191. newEntry = malloc(sizeof(httpContent));
  192. if (newEntry == NULL)
  193. return(-1);
  194. - bzero(newEntry,sizeof(httpContent));
  195. + memset(newEntry, 0, sizeof(httpContent));
  196. newEntry->name = strdup(name);
  197. newEntry->type = HTTP_STATIC;
  198. newEntry->indexFlag = indexFlag;
  199. @@ -946,7 +946,7 @@ void httpdProcessRequest(httpd *server,
  200. r->response.responseLength = 0;
  201. strncpy(dirName, httpdRequestPath(r), HTTP_MAX_URL);
  202. - cp = rindex(dirName, '/');
  203. + cp = strrchr(dirName, '/');
  204. if (cp == NULL)
  205. {
  206. printf("Invalid request path '%s'\n",dirName);