From 1744b326cc90800534d2da3203daf8eb8cd37474 Mon Sep 17 00:00:00 2001 From: pNext <843609378@qq.com> Date: Tue, 13 Dec 2022 10:27:00 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E5=88=A0=E9=99=A4=E5=A4=9A=E4=BD=99?= =?UTF-8?q?=E7=9A=84=E9=83=A8=E5=88=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ci/01-base.sh | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/ci/01-base.sh b/ci/01-base.sh index 629bffe..c025ec7 100755 --- a/ci/01-base.sh +++ b/ci/01-base.sh @@ -2,12 +2,11 @@ set +e -# cd ../ +cd ../ aclocal automake -LIBS=-ldl ./configure --without-ssl --disable-shared --without-ngtcp2 -# LIBS=-ldl ./configure --with-mesalink=/home/hanxj/mesalink/build --disable-shared --without-ngtcp2 --enable-debug +# LIBS=-ldl ./configure --without-ssl --disable-shared --without-ngtcp2 cd lib make -- Gitee From 2b357ba17dbd0964792f12646ed4a611f23489ad Mon Sep 17 00:00:00 2001 From: pNext <843609378@qq.com> Date: Tue, 13 Dec 2022 23:37:05 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E8=A7=A3=E5=86=B3http=E4=B8=AD=E5=AF=BC?= =?UTF-8?q?=E8=87=B4=E6=B5=8B=E8=AF=95=E7=94=A816=E5=A4=B1=E8=B4=A5?= =?UTF-8?q?=E7=9A=84=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- rust/rust_project/src/http.rs | 87 ++++++++++++++++------------------- 1 file changed, 40 insertions(+), 47 deletions(-) diff --git a/rust/rust_project/src/http.rs b/rust/rust_project/src/http.rs index a4d11dc..f337428 100644 --- a/rust/rust_project/src/http.rs +++ b/rust/rust_project/src/http.rs @@ -1046,14 +1046,12 @@ pub unsafe extern "C" fn Curl_http_output_auth( let mut result: CURLcode = CURLE_OK; let mut authhost: *mut auth = 0 as *mut auth; let mut authproxy: *mut auth = 0 as *mut auth; - #[cfg(all(DEBUGBUILD, HAVE_ASSERT_H))] - if !data.is_null() { - } else { + if !data.is_null() {} else { __assert_fail( b"data\0" as *const u8 as *const libc::c_char, b"http.c\0" as *const u8 as *const libc::c_char, - 805 as u32, + 805 as libc::c_int as libc::c_uint, (*::std::mem::transmute::< &[u8; 122], &[libc::c_char; 122], @@ -1063,23 +1061,21 @@ pub unsafe extern "C" fn Curl_http_output_auth( .as_ptr(), ); } - authhost = &mut (*data).state.authhost; authproxy = &mut (*data).state.authproxy; - #[cfg(not(CURL_DISABLE_PROXY))] - let flag1: bool = ((*conn).bits).httpproxy() as i32 != 0 - && ((*conn).bits).proxy_user_passwd() as i32 != 0 - || ((*conn).bits).user_passwd() as i32 != 0 - || !((*data).set.str_0[STRING_BEARER as usize]).is_null(); /* continue please */ + let flag1: bool = ((*conn).bits).httpproxy() as libc::c_int != 0 + && ((*conn).bits).proxy_user_passwd() as libc::c_int != 0 + || ((*conn).bits).user_passwd() as libc::c_int != 0 + || !((*data).set.str_0[STRING_BEARER as libc::c_int as usize]).is_null(); #[cfg(CURL_DISABLE_PROXY)] - let flag1: bool = ((*conn).bits).user_passwd() as i32 != 0 - || !((*data).set.str_0[STRING_BEARER as usize]).is_null(); /* continue please */ + let flag1: bool = ((*conn).bits).user_passwd() as libc::c_int != 0 + || !((*data).set.str_0[STRING_BEARER as libc::c_int as usize]).is_null(); if flag1 { } else { - (*authhost).set_done(1 as bit); - (*authproxy).set_done(1 as bit); - return CURLE_OK; /* no authentication with no user or password */ + (*authhost).set_done(1 as libc::c_int as bit); + (*authproxy).set_done(1 as libc::c_int as bit); + return CURLE_OK; } if (*authhost).want != 0 && (*authhost).picked == 0 { /* The app has selected one or more methods, but none has been picked @@ -1093,35 +1089,34 @@ pub unsafe extern "C" fn Curl_http_output_auth( and if this is one single bit it'll be used instantly. */ (*authproxy).picked = (*authproxy).want; } - match () { #[cfg(not(CURL_DISABLE_PROXY))] /* Send proxy authentication header if needed */ _ => { - if ((*conn).bits).httpproxy() as i32 != 0 - && ((*conn).bits).tunnel_proxy() == proxytunnel as bit - { - result = output_auth_headers(data, conn, authproxy, request, path, false); - if result as u64 != 0 { - return result; - } - } else { - (*authproxy).set_done(1 as bit); - } + if ((*conn).bits).httpproxy() as libc::c_int != 0 + && ((*conn).bits).tunnel_proxy() == proxytunnel as bit + { + result = output_auth_headers(data, conn, authproxy, request, path, 1 as libc::c_int != 0); + if result as u64 != 0 { + return result; + } + } else { + (*authproxy).set_done(1 as libc::c_int as bit); + } } /* CURL_DISABLE_PROXY */ #[cfg(CURL_DISABLE_PROXY)] /* we have no proxy so let's pretend we're done authenticating with it */ _ => { - (*authproxy).set_done(1 as bit); + (*authproxy).set_done(1 as libc::c_int as bit); } } #[cfg(not(CURL_DISABLE_NETRC))] let flag2: bool = ((*data).state).this_is_a_follow() == 0 - || ((*conn).bits).netrc() as i32 != 0 + || ((*conn).bits).netrc() as libc::c_int != 0 || ((*data).state.first_host).is_null() - || ((*data).set).allow_auth_to_other_hosts() as i32 != 0 + || ((*data).set).allow_auth_to_other_hosts() as libc::c_int != 0 || Curl_strcasecompare((*data).state.first_host, (*conn).host.name) != 0; /* To prevent the user+password to get sent to other than the original @@ -1129,23 +1124,23 @@ pub unsafe extern "C" fn Curl_http_output_auth( #[cfg(CURL_DISABLE_NETRC)] let flag2: bool = ((*data).state).this_is_a_follow() == 0 || ((*data).state.first_host).is_null() - || ((*data).set).allow_auth_to_other_hosts() as i32 != 0 + || ((*data).set).allow_auth_to_other_hosts() as libc::c_int != 0 || Curl_strcasecompare((*data).state.first_host, (*conn).host.name) != 0; if flag2 { - result = output_auth_headers(data, conn, authhost, request, path, 0 as i32 != 0); + result = output_auth_headers(data, conn, authhost, request, path, 0 as libc::c_int != 0); } else { - (*authhost).set_done(1 as bit); + (*authhost).set_done(1 as libc::c_int as bit); } - if ((*authhost).multipass() as i32 != 0 && (*authhost).done() == 0 - || (*authproxy).multipass() as i32 != 0 && (*authproxy).done() == 0) - && httpreq as u32 != HTTPREQ_GET as u32 - && httpreq as u32 != HTTPREQ_HEAD as u32 + if ((*authhost).multipass() as libc::c_int != 0 && (*authhost).done() == 0 + || (*authproxy).multipass() as libc::c_int != 0 && (*authproxy).done() == 0) + && httpreq as libc::c_uint != HTTPREQ_GET as libc::c_int as libc::c_uint + && httpreq as libc::c_uint != HTTPREQ_HEAD as libc::c_int as libc::c_uint { - /* Auth is required and we are not authenticated yet. Make a PUT or POST - with content-length zero as a "probe". */ - (*conn).bits.set_authneg(1 as bit); + let ref mut fresh8 = (*conn).bits; + (*fresh8).set_authneg(1 as libc::c_int as bit); } else { - (*conn).bits.set_authneg(0 as bit); + let ref mut fresh9 = (*conn).bits; + (*fresh9).set_authneg(0 as libc::c_int as bit); } return result; } @@ -1153,7 +1148,7 @@ pub unsafe extern "C" fn Curl_http_output_auth( /* when disabled */ #[cfg(CURL_DISABLE_HTTP_AUTH)] #[no_mangle] -pub extern "C" fn Curl_http_output_auth( +pub unsafe extern "C" fn Curl_http_output_auth( mut data: *mut Curl_easy, mut conn: *mut connectdata, mut request: *const libc::c_char, @@ -1169,12 +1164,10 @@ pub extern "C" fn Curl_http_output_auth( * headers. They are dealt with both in the transfer.c main loop and in the * proxy CONNECT loop. */ -extern "C" fn is_valid_auth_separator(mut ch: libc::c_char) -> i32 { - unsafe { - return (ch as i32 == '\0' as i32 - || ch as i32 == ',' as i32 - || Curl_isspace(ch as u8 as i32) != 0) as i32; - } +unsafe extern "C" fn is_valid_auth_separator(mut ch: libc::c_char) -> libc::c_int { + return (ch as libc::c_int == '\0' as i32 + || ch as libc::c_int == ',' as i32 + || Curl_isspace(ch as libc::c_uchar as libc::c_int) != 0) as libc::c_int; } #[no_mangle] -- Gitee From 0a87f05e4c6bc815a2f7a020e91c7c4318041fe8 Mon Sep 17 00:00:00 2001 From: pNext <843609378@qq.com> Date: Tue, 13 Dec 2022 23:37:30 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E8=A7=A3=E5=86=B3http=E4=B8=AD=E5=AF=BC?= =?UTF-8?q?=E8=87=B4=E6=B5=8B=E8=AF=95=E7=94=A816=E5=A4=B1=E8=B4=A5?= =?UTF-8?q?=E7=9A=84=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ci/01-base.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ci/01-base.sh b/ci/01-base.sh index c025ec7..fd58315 100755 --- a/ci/01-base.sh +++ b/ci/01-base.sh @@ -3,10 +3,14 @@ set +e cd ../ + +make clean + aclocal automake # LIBS=-ldl ./configure --without-ssl --disable-shared --without-ngtcp2 +LIBS=-ldl ./configure --with-openssl --disable-shared --without-ngtcp2 --enable-http --enable-ipv6 --with-gssapi cd lib make -- Gitee From 788033c21f13e7265adad37857c1110eb4ee278a Mon Sep 17 00:00:00 2001 From: pNext <843609378@qq.com> Date: Wed, 14 Dec 2022 12:41:18 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dhttp=E4=B8=AD=E7=9A=84?= =?UTF-8?q?=E5=AF=BC=E8=87=B4=E6=B5=8B=E8=AF=95=E7=94=A8=E4=BE=8B24?= =?UTF-8?q?=E9=94=99=E8=AF=AF=E7=9A=84bug=EF=BC=8C=E5=87=BD=E6=95=B0http?= =?UTF-8?q?=5Fshould=5Ffail=E4=B8=AD=E7=9A=84=E8=BF=94=E5=9B=9E=E5=80=BC?= =?UTF-8?q?=E8=AF=AF=E5=86=99=E4=B8=BAfalse?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ci/01-base.sh | 7 +++---- rust/rust_project/src/http.rs | 4 +++- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/ci/01-base.sh b/ci/01-base.sh index fd58315..40e22dd 100755 --- a/ci/01-base.sh +++ b/ci/01-base.sh @@ -2,15 +2,14 @@ set +e -cd ../ +# cd ../ -make clean +# make clean aclocal automake -# LIBS=-ldl ./configure --without-ssl --disable-shared --without-ngtcp2 -LIBS=-ldl ./configure --with-openssl --disable-shared --without-ngtcp2 --enable-http --enable-ipv6 --with-gssapi +LIBS=-ldl ./configure --without-ssl --disable-shared --without-ngtcp2 cd lib make diff --git a/rust/rust_project/src/http.rs b/rust/rust_project/src/http.rs index f337428..ee5cdfb 100644 --- a/rust/rust_project/src/http.rs +++ b/rust/rust_project/src/http.rs @@ -1440,6 +1440,7 @@ pub unsafe extern "C" fn Curl_http_input_auth( */ unsafe extern "C" fn http_should_fail(mut data: *mut Curl_easy) -> bool { let mut httpcode: i32 = 0; + #[cfg(all(DEBUGBUILD, HAVE_ASSERT_H))] if !data.is_null() { } else { @@ -1453,6 +1454,7 @@ unsafe extern "C" fn http_should_fail(mut data: *mut Curl_easy) -> bool { .as_ptr(), ); } + #[cfg(all(DEBUGBUILD, HAVE_ASSERT_H))] if !((*data).conn).is_null() { } else { @@ -1500,7 +1502,7 @@ unsafe extern "C" fn http_should_fail(mut data: *mut Curl_easy) -> bool { ** a terminal error */ if httpcode != 401 && httpcode != 407 { - return false; + return true; } /* -- Gitee