Commit cdba33c4 authored by James Almer's avatar James Almer

Merge commit 'b62ed687'

* commit 'b62ed687':
  configure: Better names for functions that sanitize input
Merged-by: 's avatarJames Almer <jamrial@gmail.com>
parents c64800e9 b62ed687
...@@ -584,13 +584,13 @@ sanitize_var_name(){ ...@@ -584,13 +584,13 @@ sanitize_var_name(){
echo $@ | sed 's/[^A-Za-z0-9_]/_/g' echo $@ | sed 's/[^A-Za-z0-9_]/_/g'
} }
set_safe(){ set_sanitized(){
var=$1 var=$1
shift shift
eval $(sanitize_var_name "$var")='$*' eval $(sanitize_var_name "$var")='$*'
} }
get_safe(){ get_sanitized(){
eval echo \$$(sanitize_var_name "$1") eval echo \$$(sanitize_var_name "$1")
} }
...@@ -636,13 +636,13 @@ disable_weak(){ ...@@ -636,13 +636,13 @@ disable_weak(){
set_weak no $* set_weak no $*
} }
enable_safe(){ enable_sanitized(){
for var; do for var; do
enable $(echo "$var" | sed 's/[^A-Za-z0-9_]/_/g') enable $(echo "$var" | sed 's/[^A-Za-z0-9_]/_/g')
done done
} }
disable_safe(){ disable_sanitized(){
for var; do for var; do
disable $(echo "$var" | sed 's/[^A-Za-z0-9_]/_/g') disable $(echo "$var" | sed 's/[^A-Za-z0-9_]/_/g')
done done
...@@ -1108,8 +1108,8 @@ check_header(){ ...@@ -1108,8 +1108,8 @@ check_header(){
log check_header "$@" log check_header "$@"
header=$1 header=$1
shift shift
disable_safe $header disable_sanitized $header
check_cpp "$@" <<EOF && enable_safe $header check_cpp "$@" <<EOF && enable_sanitized $header
#include <$header> #include <$header>
int x; int x;
EOF EOF
...@@ -1120,11 +1120,11 @@ check_header_objcc(){ ...@@ -1120,11 +1120,11 @@ check_header_objcc(){
rm -f -- "$TMPO" rm -f -- "$TMPO"
header=$1 header=$1
shift shift
disable_safe $header disable_sanitized $header
{ {
echo "#include <$header>" echo "#include <$header>"
echo "int main(void) { return 0; }" echo "int main(void) { return 0; }"
} | check_objcc && check_stat "$TMPO" && enable_safe $header } | check_objcc && check_stat "$TMPO" && enable_sanitized $header
} }
check_apple_framework(){ check_apple_framework(){
...@@ -1196,7 +1196,7 @@ check_func_headers(){ ...@@ -1196,7 +1196,7 @@ check_func_headers(){
echo " ret |= ((intptr_t)check_$func) & 0xFFFF;" echo " ret |= ((intptr_t)check_$func) & 0xFFFF;"
done done
echo "return ret; }" echo "return ret; }"
} | check_ld "cc" "$@" && enable $funcs && enable_safe $headers } | check_ld "cc" "$@" && enable $funcs && enable_sanitized $headers
} }
check_class_headers_cpp(){ check_class_headers_cpp(){
...@@ -1215,7 +1215,7 @@ check_class_headers_cpp(){ ...@@ -1215,7 +1215,7 @@ check_class_headers_cpp(){
i=$(expr $i + 1) i=$(expr $i + 1)
done done
echo "return 0; }" echo "return 0; }"
} | check_ld "cxx" "$@" && enable $funcs && enable_safe $headers } | check_ld "cxx" "$@" && enable $funcs && enable_sanitized $headers
} }
check_cpp_condition(){ check_cpp_condition(){
...@@ -1282,8 +1282,8 @@ check_pkg_config(){ ...@@ -1282,8 +1282,8 @@ check_pkg_config(){
pkg_libs=$($pkg_config --libs $pkg_config_flags $pkg) pkg_libs=$($pkg_config --libs $pkg_config_flags $pkg)
check_func_headers "$headers" "$funcs" $pkg_cflags $pkg_libs "$@" && check_func_headers "$headers" "$funcs" $pkg_cflags $pkg_libs "$@" &&
enable $name && enable $name &&
set_safe "${name}_cflags" $pkg_cflags && set_sanitized "${name}_cflags" $pkg_cflags &&
set_safe "${name}_extralibs" $pkg_libs set_sanitized "${name}_extralibs" $pkg_libs
} }
check_exec(){ check_exec(){
...@@ -1326,8 +1326,8 @@ check_type(){ ...@@ -1326,8 +1326,8 @@ check_type(){
headers=$1 headers=$1
type=$2 type=$2
shift 2 shift 2
disable_safe "$type" disable_sanitized "$type"
check_code cc "$headers" "$type v" "$@" && enable_safe "$type" check_code cc "$headers" "$type v" "$@" && enable_sanitized "$type"
} }
check_struct(){ check_struct(){
...@@ -1336,9 +1336,9 @@ check_struct(){ ...@@ -1336,9 +1336,9 @@ check_struct(){
struct=$2 struct=$2
member=$3 member=$3
shift 3 shift 3
disable_safe "${struct}_${member}" disable_sanitized "${struct}_${member}"
check_code cc "$headers" "const void *p = &(($struct *)0)->$member" "$@" && check_code cc "$headers" "const void *p = &(($struct *)0)->$member" "$@" &&
enable_safe "${struct}_${member}" enable_sanitized "${struct}_${member}"
} }
check_builtin(){ check_builtin(){
...@@ -1398,7 +1398,7 @@ use_pkg_config(){ ...@@ -1398,7 +1398,7 @@ use_pkg_config(){
log use_pkg_config "$@" log use_pkg_config "$@"
name="$1" name="$1"
check_pkg_config "$@" || return 1 check_pkg_config "$@" || return 1
add_cflags $(get_safe "${name}_cflags") add_cflags $(get_sanitized "${name}_cflags")
} }
require_pkg_config(){ require_pkg_config(){
...@@ -6183,7 +6183,7 @@ rsync --help 2> /dev/null | grep -q 'contimeout' && enable rsync_contimeout || d ...@@ -6183,7 +6183,7 @@ rsync --help 2> /dev/null | grep -q 'contimeout' && enable rsync_contimeout || d
# check V4L2 codecs available in the API # check V4L2 codecs available in the API
check_header linux/fb.h check_header linux/fb.h
check_header linux/videodev2.h check_header linux/videodev2.h
check_code cc linux/videodev2.h "struct v4l2_frmsizeenum vfse; vfse.discrete.width = 0;" && enable_safe struct_v4l2_frmivalenum_discrete check_code cc linux/videodev2.h "struct v4l2_frmsizeenum vfse; vfse.discrete.width = 0;" && enable_sanitized struct_v4l2_frmivalenum_discrete
check_code cc linux/videodev2.h "int i = V4L2_CAP_VIDEO_M2M_MPLANE | V4L2_CAP_VIDEO_M2M | V4L2_BUF_FLAG_LAST;" || disable v4l2_m2m check_code cc linux/videodev2.h "int i = V4L2_CAP_VIDEO_M2M_MPLANE | V4L2_CAP_VIDEO_M2M | V4L2_BUF_FLAG_LAST;" || disable v4l2_m2m
check_code cc linux/videodev2.h "int i = V4L2_PIX_FMT_VC1_ANNEX_G;" && enable vc1_v4l2_m2m check_code cc linux/videodev2.h "int i = V4L2_PIX_FMT_VC1_ANNEX_G;" && enable vc1_v4l2_m2m
check_code cc linux/videodev2.h "int i = V4L2_PIX_FMT_MPEG1;" && enable mpeg1_v4l2_m2m check_code cc linux/videodev2.h "int i = V4L2_PIX_FMT_MPEG1;" && enable mpeg1_v4l2_m2m
...@@ -6196,7 +6196,7 @@ check_code cc linux/videodev2.h "int i = V4L2_PIX_FMT_VP8;" && enable vp8_v4l2_m ...@@ -6196,7 +6196,7 @@ check_code cc linux/videodev2.h "int i = V4L2_PIX_FMT_VP8;" && enable vp8_v4l2_m
check_code cc linux/videodev2.h "int i = V4L2_PIX_FMT_VP9;" && enable vp9_v4l2_m2m check_code cc linux/videodev2.h "int i = V4L2_PIX_FMT_VP9;" && enable vp9_v4l2_m2m
check_header sys/videoio.h check_header sys/videoio.h
check_code cc sys/videoio.h "struct v4l2_frmsizeenum vfse; vfse.discrete.width = 0;" && enable_safe struct_v4l2_frmivalenum_discrete check_code cc sys/videoio.h "struct v4l2_frmsizeenum vfse; vfse.discrete.width = 0;" && enable_sanitized struct_v4l2_frmivalenum_discrete
check_lib user32 "windows.h winuser.h" GetShellWindow -luser32 check_lib user32 "windows.h winuser.h" GetShellWindow -luser32
check_lib vfw32 "windows.h vfw.h" capCreateCaptureWindow -lvfw32 check_lib vfw32 "windows.h vfw.h" capCreateCaptureWindow -lvfw32
...@@ -6216,9 +6216,9 @@ check_type "dshow.h" IBaseFilter ...@@ -6216,9 +6216,9 @@ check_type "dshow.h" IBaseFilter
check_header dev/ic/bt8xx.h check_header dev/ic/bt8xx.h
if check_struct sys/soundcard.h audio_buf_info bytes; then if check_struct sys/soundcard.h audio_buf_info bytes; then
enable_safe sys/soundcard.h enable_sanitized sys/soundcard.h
else else
check_cc -D__BSD_VISIBLE -D__XSI_VISIBLE <<EOF && add_cppflags -D__BSD_VISIBLE -D__XSI_VISIBLE && enable_safe sys/soundcard.h check_cc -D__BSD_VISIBLE -D__XSI_VISIBLE <<EOF && add_cppflags -D__BSD_VISIBLE -D__XSI_VISIBLE && enable_sanitized sys/soundcard.h
#include <sys/soundcard.h> #include <sys/soundcard.h>
audio_buf_info abc; audio_buf_info abc;
EOF EOF
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment