Merge pull request #651 from Rehan-MALAK/null-character
add '\0' terminal character
This commit is contained in:
commit
b142f3d179
@ -128,7 +128,8 @@ PT_THREAD(handle_output(struct httpd_state *s))
|
||||
s->script = NULL;
|
||||
s->script = httpd_simple_get_script(&s->filename[1]);
|
||||
if(s->script == NULL) {
|
||||
strncpy(s->filename, "/notfound.html", sizeof(s->filename));
|
||||
strncpy(s->filename, "/notfound.html", sizeof(s->filename) - 1);
|
||||
s->filename[sizeof(s->filename) - 1] = '\0';
|
||||
PT_WAIT_THREAD(&s->outputpt,
|
||||
send_headers(s, http_header_404));
|
||||
PT_WAIT_THREAD(&s->outputpt,
|
||||
@ -170,7 +171,8 @@ PT_THREAD(handle_input(struct httpd_state *s))
|
||||
urlconv_tofilename(s->filename, s->inputbuf, sizeof(s->filename));
|
||||
#else /* URLCONV */
|
||||
if(s->inputbuf[1] == ISO_space) {
|
||||
strncpy(s->filename, http_index_html, sizeof(s->filename));
|
||||
strncpy(s->filename, http_index_html, sizeof(s->filename) - 1);
|
||||
s->filename[sizeof(s->filename) - 1] = '\0';
|
||||
} else {
|
||||
s->inputbuf[PSOCK_DATALEN(&s->sin) - 1] = 0;
|
||||
strncpy(s->filename, s->inputbuf, sizeof(s->filename));
|
||||
|
@ -579,8 +579,10 @@ tun_alloc(char *dev, int tap)
|
||||
* IFF_NO_PI - Do not provide packet information
|
||||
*/
|
||||
ifr.ifr_flags = (tap ? IFF_TAP : IFF_TUN) | IFF_NO_PI;
|
||||
if(*dev != 0)
|
||||
strncpy(ifr.ifr_name, dev, IFNAMSIZ);
|
||||
if(*dev != 0) {
|
||||
strncpy(ifr.ifr_name, dev, sizeof(ifr.ifr_name) - 1);
|
||||
ifr.ifr_name[sizeof(ifr.ifr_name) - 1] = '\0';
|
||||
}
|
||||
|
||||
if((err = ioctl(fd, TUNSETIFF, (void *) &ifr)) < 0 ) {
|
||||
close(fd);
|
||||
@ -793,9 +795,9 @@ main(int argc, char **argv)
|
||||
|
||||
case 's':
|
||||
if(strncmp("/dev/", optarg, 5) == 0) {
|
||||
siodev = optarg + 5;
|
||||
siodev = optarg + 5;
|
||||
} else {
|
||||
siodev = optarg;
|
||||
siodev = optarg;
|
||||
}
|
||||
break;
|
||||
|
||||
@ -806,10 +808,11 @@ main(int argc, char **argv)
|
||||
|
||||
case 't':
|
||||
if(strncmp("/dev/", optarg, 5) == 0) {
|
||||
strncpy(tundev, optarg + 5, sizeof(tundev));
|
||||
strncpy(tundev, optarg + 5, sizeof(tundev) - 1);
|
||||
} else {
|
||||
strncpy(tundev, optarg, sizeof(tundev));
|
||||
strncpy(tundev, optarg, sizeof(tundev) - 1);
|
||||
}
|
||||
tundev[sizeof(tundev) - 1] = '\0';
|
||||
break;
|
||||
|
||||
case 'a':
|
||||
|
Loading…
Reference in New Issue
Block a user