More changes for issues reported by CppCheck
This commit is contained in:
parent
f70d3958e4
commit
2f720ee01f
@ -97,15 +97,15 @@
|
|||||||
#ifndef CONFIG_ENDIAN_BIG
|
#ifndef CONFIG_ENDIAN_BIG
|
||||||
# define byteReverse(buf, len)
|
# define byteReverse(buf, len)
|
||||||
#else
|
#else
|
||||||
static void byteReverse(unsigned char *buf, unsigned longs)
|
static void byteReverse(FAR unsigned char *buf, unsigned longs)
|
||||||
{
|
{
|
||||||
uint32_t t;
|
uint32_t t;
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
t = ((uint32_t)buf[3] << 8) |
|
t = ((uint32_t)buf[3] << 24) |
|
||||||
((uint32_t)buf[2]) << 16) |
|
((uint32_t)buf[2] << 16) |
|
||||||
((uint32_t)buf[1] << 8) |
|
((uint32_t)buf[1] << 8) |
|
||||||
(uint32_t)buf[0];
|
(uint32_t)buf[0];
|
||||||
|
|
||||||
*(uint32_t*)buf = t;
|
*(uint32_t*)buf = t;
|
||||||
buf += 4;
|
buf += 4;
|
||||||
|
@ -270,25 +270,27 @@ static inline int discover_respond(in_addr_t *ipaddr)
|
|||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
sockfd = discover_openresponder();
|
sockfd = discover_openresponder();
|
||||||
if (sockfd >= 0)
|
if (sockfd < 0)
|
||||||
{
|
{
|
||||||
/* Then send the reponse to the DHCP client port at that address */
|
ndbg("discover_openresponder failed\n");
|
||||||
|
return ERROR;
|
||||||
memset(&addr, 0, sizeof(struct sockaddr_in));
|
|
||||||
addr.sin_family = AF_INET;
|
|
||||||
addr.sin_port = HTONS(CONFIG_DISCOVER_PORT);
|
|
||||||
addr.sin_addr.s_addr = *ipaddr;
|
|
||||||
|
|
||||||
ret = sendto(sockfd, &g_state.response, sizeof(g_state.response), 0,
|
|
||||||
(struct sockaddr *)&addr, sizeof(struct sockaddr_in));
|
|
||||||
if (ret < 0)
|
|
||||||
{
|
|
||||||
ndbg("Could not send discovery response: %d\n", errno);
|
|
||||||
}
|
|
||||||
|
|
||||||
close(sockfd);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Then send the reponse to the DHCP client port at that address */
|
||||||
|
|
||||||
|
memset(&addr, 0, sizeof(struct sockaddr_in));
|
||||||
|
addr.sin_family = AF_INET;
|
||||||
|
addr.sin_port = HTONS(CONFIG_DISCOVER_PORT);
|
||||||
|
addr.sin_addr.s_addr = *ipaddr;
|
||||||
|
|
||||||
|
ret = sendto(sockfd, &g_state.response, sizeof(g_state.response), 0,
|
||||||
|
(struct sockaddr *)&addr, sizeof(struct sockaddr_in));
|
||||||
|
if (ret < 0)
|
||||||
|
{
|
||||||
|
ndbg("Could not send discovery response: %d\n", errno);
|
||||||
|
}
|
||||||
|
|
||||||
|
close(sockfd);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -519,7 +519,7 @@ static int send_err_file(httpd_conn *hc, int status, char *title, char *extrahea
|
|||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* CONFIG_THTTPD_ERROR_DIRECTORY */
|
||||||
|
|
||||||
#ifdef CONFIG_THTTPD_AUTH_FILE
|
#ifdef CONFIG_THTTPD_AUTH_FILE
|
||||||
static void send_authenticate(httpd_conn *hc, char *realm)
|
static void send_authenticate(httpd_conn *hc, char *realm)
|
||||||
@ -664,7 +664,8 @@ static int auth_check(httpd_conn *hc, char *dirname)
|
|||||||
case 1:
|
case 1:
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* CONFIG_THTTPD_GLOBALPASSWD */
|
||||||
|
|
||||||
return auth_check2(hc, dirname);
|
return auth_check2(hc, dirname);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -906,7 +907,7 @@ static int httpd_tilde_map1(httpd_conn *hc)
|
|||||||
(void)strcat(hc->expnfilename, temp);
|
(void)strcat(hc->expnfilename, temp);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* CONFIG_THTTPD_TILDE_MAP1 */
|
||||||
|
|
||||||
/* Map a ~username/whatever URL into <user's homedir>/<postfix>. */
|
/* Map a ~username/whatever URL into <user's homedir>/<postfix>. */
|
||||||
|
|
||||||
@ -973,7 +974,7 @@ static int httpd_tilde_map2(httpd_conn *hc)
|
|||||||
hc->tildemapped = true;
|
hc->tildemapped = true;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* CONFIG_THTTPD_TILDE_MAP2 */
|
||||||
|
|
||||||
/* Virtual host mapping. */
|
/* Virtual host mapping. */
|
||||||
|
|
||||||
@ -1030,6 +1031,7 @@ static int vhost_map(httpd_conn *hc)
|
|||||||
/* Figure out the host directory. */
|
/* Figure out the host directory. */
|
||||||
|
|
||||||
#ifdef VHOST_DIRLEVELS
|
#ifdef VHOST_DIRLEVELS
|
||||||
|
|
||||||
httpd_realloc_str(&hc->hostdir, &hc->maxhostdir, strlen(hc->vhostname) + 2 * VHOST_DIRLEVELS);
|
httpd_realloc_str(&hc->hostdir, &hc->maxhostdir, strlen(hc->vhostname) + 2 * VHOST_DIRLEVELS);
|
||||||
if (strncmp(hc->vhostname, "www.", 4) == 0)
|
if (strncmp(hc->vhostname, "www.", 4) == 0)
|
||||||
{
|
{
|
||||||
@ -1070,10 +1072,13 @@ static int vhost_map(httpd_conn *hc)
|
|||||||
*cp2++ = '/';
|
*cp2++ = '/';
|
||||||
}
|
}
|
||||||
(void)strcpy(cp2, hc->vhostname);
|
(void)strcpy(cp2, hc->vhostname);
|
||||||
|
|
||||||
#else /* VHOST_DIRLEVELS */
|
#else /* VHOST_DIRLEVELS */
|
||||||
|
|
||||||
httpd_realloc_str(&hc->hostdir, &hc->maxhostdir, strlen(hc->vhostname));
|
httpd_realloc_str(&hc->hostdir, &hc->maxhostdir, strlen(hc->vhostname));
|
||||||
(void)strcpy(hc->hostdir, hc->vhostname);
|
(void)strcpy(hc->hostdir, hc->vhostname);
|
||||||
#endif /* VHOST_DIRLEVELS */
|
|
||||||
|
#endif /* VHOST_DIRLEVELS */
|
||||||
|
|
||||||
/* Prepend hostdir to the filename. */
|
/* Prepend hostdir to the filename. */
|
||||||
|
|
||||||
@ -1134,7 +1139,7 @@ static char *expand_filename(char *path, char **restP, bool tildemapped)
|
|||||||
*restP = rest;
|
*restP = rest;
|
||||||
return checked;
|
return checked;
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* 0 */
|
||||||
|
|
||||||
/* Handle leading / or . and relative pathes by copying the default directory into checked */
|
/* Handle leading / or . and relative pathes by copying the default directory into checked */
|
||||||
|
|
||||||
@ -1944,10 +1949,14 @@ static int check_referer(httpd_conn *hc)
|
|||||||
"You must supply a local referer to get URL '%s' from this server.\n"),
|
"You must supply a local referer to get URL '%s' from this server.\n"),
|
||||||
hc->encodedurl);
|
hc->encodedurl);
|
||||||
}
|
}
|
||||||
|
|
||||||
return r;
|
return r;
|
||||||
#else
|
|
||||||
|
#else /* CONFIG_THTTPD_URLPATTERN */
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
#endif
|
|
||||||
|
#endif /* CONFIG_THTTPD_URLPATTERN */
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Returns 1 if ok to serve the url, 0 if not. */
|
/* Returns 1 if ok to serve the url, 0 if not. */
|
||||||
@ -2035,25 +2044,23 @@ static int really_check_referer(httpd_conn *hc)
|
|||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* CONFIG_THTTPD_VHOST */
|
||||||
#endif /* CONFIG_THTTPD_LOCALPATTERN */
|
#endif /* CONFIG_THTTPD_LOCALPATTERN */
|
||||||
|
|
||||||
/* If the referer host doesn't match the local host pattern, and the
|
/* If the referer host doesn't match the local host pattern, and the
|
||||||
* filename does match the url pattern, it's an illegal reference.
|
* filename does match the url pattern, it's an illegal reference.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef CONFIG_THTTPD_URLPATTERN
|
|
||||||
if (!match(lp, refhost) && match(CONFIG_THTTPD_URLPATTERN, hc->origfilename))
|
if (!match(lp, refhost) && match(CONFIG_THTTPD_URLPATTERN, hc->origfilename))
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Otherwise ok. */
|
/* Otherwise ok. */
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* CONFIG_THTTPD_URLPATTERN */
|
||||||
|
|
||||||
#ifdef CONFIG_DEBUG
|
#ifdef CONFIG_DEBUG
|
||||||
static int sockaddr_check(httpd_sockaddr *saP)
|
static int sockaddr_check(httpd_sockaddr *saP)
|
||||||
@ -2072,7 +2079,7 @@ static int sockaddr_check(httpd_sockaddr *saP)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* CONFIG_DEBUG */
|
||||||
|
|
||||||
static size_t sockaddr_len(httpd_sockaddr *saP)
|
static size_t sockaddr_len(httpd_sockaddr *saP)
|
||||||
{
|
{
|
||||||
@ -2234,7 +2241,7 @@ void httpd_send_err(httpd_conn *hc, int status, const char *title, const char *e
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* CONFIG_THTTPD_VHOST */
|
||||||
|
|
||||||
/* Try server-wide error page. */
|
/* Try server-wide error page. */
|
||||||
|
|
||||||
@ -2249,11 +2256,11 @@ void httpd_send_err(httpd_conn *hc, int status, const char *title, const char *e
|
|||||||
|
|
||||||
send_response(hc, status, title, extraheads, form, arg);
|
send_response(hc, status, title, extraheads, form, arg);
|
||||||
|
|
||||||
#else
|
#else /* CONFIG_THTTPD_ERROR_DIRECTORY */
|
||||||
|
|
||||||
send_response(hc, status, title, extraheads, form, arg);
|
send_response(hc, status, title, extraheads, form, arg);
|
||||||
|
|
||||||
#endif
|
#endif /* CONFIG_THTTPD_ERROR_DIRECTORY */
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *httpd_method_str(int method)
|
const char *httpd_method_str(int method)
|
||||||
@ -2959,7 +2966,7 @@ int httpd_parse_request(httpd_conn *hc)
|
|||||||
{
|
{
|
||||||
ndbg("unknown request header: %s\n", buf);
|
ndbg("unknown request header: %s\n", buf);
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* LOG_UNKNOWN_HEADERS */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3122,7 +3129,7 @@ void httpd_destroy_conn(httpd_conn *hc)
|
|||||||
httpd_free((void *)hc->buffer);
|
httpd_free((void *)hc->buffer);
|
||||||
#ifdef CONFIG_THTTPD_TILDE_MAP2
|
#ifdef CONFIG_THTTPD_TILDE_MAP2
|
||||||
httpd_free((void *)hc->altdir);
|
httpd_free((void *)hc->altdir);
|
||||||
#endif /*CONFIG_THTTPD_TILDE_MAP2 */
|
#endif /*CONFIG_THTTPD_TILDE_MAP2 */
|
||||||
hc->initialized = 0;
|
hc->initialized = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -3134,7 +3141,7 @@ int httpd_start_request(httpd_conn *hc, struct timeval *nowP)
|
|||||||
#ifdef CONFIG_THTTPD_AUTH_FILE
|
#ifdef CONFIG_THTTPD_AUTH_FILE
|
||||||
static char *dirname;
|
static char *dirname;
|
||||||
static size_t maxdirname = 0;
|
static size_t maxdirname = 0;
|
||||||
#endif /* CONFIG_THTTPD_AUTH_FILE */
|
#endif /* CONFIG_THTTPD_AUTH_FILE */
|
||||||
size_t expnlen, indxlen;
|
size_t expnlen, indxlen;
|
||||||
char *cp;
|
char *cp;
|
||||||
char *pi;
|
char *pi;
|
||||||
@ -3258,8 +3265,10 @@ int httpd_start_request(httpd_conn *hc, struct timeval *nowP)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Ok, generate an index. */
|
/* Ok, generate an index. */
|
||||||
|
|
||||||
return ls(hc);
|
return ls(hc);
|
||||||
#else
|
#else /* CONFIG_THTTPD_GENERATE_INDICES */
|
||||||
|
|
||||||
ndbg("%s URL \"%s\" tried to index a directory\n",
|
ndbg("%s URL \"%s\" tried to index a directory\n",
|
||||||
httpd_ntoa(&hc->client_addr), hc->encodedurl);
|
httpd_ntoa(&hc->client_addr), hc->encodedurl);
|
||||||
httpd_send_err(hc, 403, err403title, "",
|
httpd_send_err(hc, 403, err403title, "",
|
||||||
@ -3267,7 +3276,7 @@ int httpd_start_request(httpd_conn *hc, struct timeval *nowP)
|
|||||||
"The requested URL '%s' is a directory, and directory indexing is disabled on this server.\n"),
|
"The requested URL '%s' is a directory, and directory indexing is disabled on this server.\n"),
|
||||||
hc->encodedurl);
|
hc->encodedurl);
|
||||||
return -1;
|
return -1;
|
||||||
#endif
|
#endif /* CONFIG_THTTPD_GENERATE_INDICES */
|
||||||
|
|
||||||
got_one:
|
got_one:
|
||||||
|
|
||||||
@ -3349,7 +3358,7 @@ int httpd_start_request(httpd_conn *hc, struct timeval *nowP)
|
|||||||
hc->encodedurl);
|
hc->encodedurl);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* CONFIG_THTTPD_AUTH_FILE */
|
||||||
|
|
||||||
/* Referer check. */
|
/* Referer check. */
|
||||||
|
|
||||||
@ -3455,7 +3464,7 @@ char *httpd_ntoa(httpd_sockaddr *saP)
|
|||||||
|
|
||||||
return inet_ntoa(saP->sin_addr);
|
return inet_ntoa(saP->sin_addr);
|
||||||
|
|
||||||
#endif
|
#endif /* CONFIG_NET_IPv6 */
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Read to requested buffer, accounting for interruptions and EOF */
|
/* Read to requested buffer, accounting for interruptions and EOF */
|
||||||
@ -3523,4 +3532,3 @@ int httpd_write(int fd, const void *buf, size_t nbytes)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#endif /* CONFIG_THTTPD */
|
#endif /* CONFIG_THTTPD */
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user