Change match to fnmatch

follow the kernel side change

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
This commit is contained in:
Xiang Xiao 2021-08-01 23:20:18 +08:00 committed by Alan Carvalho de Assis
parent 1120bc844a
commit ad3f44bc77
3 changed files with 11 additions and 12 deletions

View File

@ -7,7 +7,7 @@
* *
* Derived from the file of the same name in the original THTTPD package: * Derived from the file of the same name in the original THTTPD package:
* *
* Copyright © 1995 by Jef Poskanzer <jef@mail.acme.com>. * Copyright 1995 by Jef Poskanzer <jef@mail.acme.com>.
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -46,8 +46,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <errno.h> #include <errno.h>
#include <fnmatch.h>
#include <nuttx/lib/regex.h>
#include "config.h" #include "config.h"
@ -339,7 +338,7 @@ static int check_filename(char *filename)
/* Ensure that we are not reading a CGI file. */ /* Ensure that we are not reading a CGI file. */
if (cgi_pattern != (char *)0 && match(cgi_pattern, filename)) if (cgi_pattern != (char *)0 && !fnmatch(cgi_pattern, filename, 0))
{ {
return 0; return 0;
} }

View File

@ -7,7 +7,7 @@
* *
* Derived from the file of the same name in the original THTTPD package: * Derived from the file of the same name in the original THTTPD package:
* *
* Copyright © 1995,1998,1999,2000,2001 by Jef Poskanzer <jef@mail.acme.com>. * Copyright 1995,1998,1999,2000,2001 by Jef Poskanzer <jef@mail.acme.com>.
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -59,8 +59,8 @@
#include <sched.h> #include <sched.h>
#include <errno.h> #include <errno.h>
#include <debug.h> #include <debug.h>
#include <fnmatch.h>
#include <nuttx/lib/regex.h>
#include "netutils/thttpd.h" #include "netutils/thttpd.h"
#include "config.h" #include "config.h"
@ -436,7 +436,7 @@ static void send_response(httpd_conn *hc, int status, const char *title, const c
snprintf(buf, sizeof(buf), form, defanged); snprintf(buf, sizeof(buf), form, defanged);
add_response(hc, buf); add_response(hc, buf);
if (match("**MSIE**", hc->useragent)) if (!fnmatch("**MSIE**", hc->useragent, 0))
{ {
int n; int n;
add_response(hc, "<!--\n"); add_response(hc, "<!--\n");
@ -1960,7 +1960,7 @@ static int really_check_referer(httpd_conn *hc)
{ {
/* Disallow if the url matches. */ /* Disallow if the url matches. */
if (match(CONFIG_THTTPD_URLPATTERN, hc->origfilename)) if (!fnmatch(CONFIG_THTTPD_URLPATTERN, hc->origfilename, 0))
{ {
return 0; return 0;
} }
@ -2030,7 +2030,7 @@ static int really_check_referer(httpd_conn *hc)
* filename does match the url pattern, it's an illegal reference. * filename does match the url pattern, it's an illegal reference.
*/ */
if (!match(lp, refhost) && match(CONFIG_THTTPD_URLPATTERN, hc->origfilename)) if (fnmatch(lp, refhost, 0) && !fnmatch(CONFIG_THTTPD_URLPATTERN, hc->origfilename, 0))
{ {
return 0; return 0;
} }
@ -3352,7 +3352,7 @@ int httpd_start_request(httpd_conn *hc, struct timeval *nowP)
/* Is it in the CGI area? */ /* Is it in the CGI area? */
#ifdef CONFIG_THTTPD_CGI_PATTERN #ifdef CONFIG_THTTPD_CGI_PATTERN
if (match(CONFIG_THTTPD_CGI_PATTERN, hc->expnfilename)) if (!fnmatch(CONFIG_THTTPD_CGI_PATTERN, hc->expnfilename, 0))
{ {
return cgi(hc); return cgi(hc);
} }

View File

@ -30,8 +30,8 @@
#include <unistd.h> #include <unistd.h>
#include <errno.h> #include <errno.h>
#include <fcntl.h> #include <fcntl.h>
#include <fnmatch.h>
#include <sys/ioctl.h> #include <sys/ioctl.h>
#include <nuttx/lib/regex.h>
#include <nuttx/note/notectl_driver.h> #include <nuttx/note/notectl_driver.h>
#include "trace.h" #include "trace.h"
@ -473,7 +473,7 @@ static int trace_cmd_syscall(int index, int argc, FAR char **argv,
for (syscallno = 0; syscallno < SYS_nsyscalls; syscallno++) for (syscallno = 0; syscallno < SYS_nsyscalls; syscallno++)
{ {
if (!match(&argv[index][1], g_funcnames[syscallno])) if (fnmatch(&argv[index][1], g_funcnames[syscallno], 0))
{ {
continue; continue;
} }