History

avformat/tls_schannel: add check for Windows 10 only types and defines

Old Mingw-w64 releases provided by some distros seemingly don't have them, so check for them and disable the dtls protocol if unavailable.

James Almer committed 1 year ago

Commit 307983b1 parent 053a1132 files · +35 −2Browse files

Unified · Split

2 files
  1. configure +4 −0
  2. libavformat/tls_schannel.c +31 −2
configure+4−0
@@ -2498,6 +2498,7 @@ TYPES_LIST=" · 2497 unmodified lines
24982498 kCVImageBufferTransferFunction_ITU_R_2020
24992499 kCVImageBufferTransferFunction_SMPTE_ST_428_1
25002500 kVTQPModulationLevel_Default
2501+ SecPkgContext_KeyingMaterialInfo
25012502 socklen_t
25022503 struct_addrinfo
25032504 struct_group_source_req
@@ -6822,6 +6823,7 @@ check_type "windows.h d3d12video.h" "ID3D12VideoEncoder" · 4318 unmodified lines
68226823 test_code cc "windows.h d3d12video.h" "D3D12_FEATURE_VIDEO feature = D3D12_FEATURE_VIDEO_ENCODER_CODEC" && \
68236824 test_code cc "windows.h d3d12video.h" "D3D12_FEATURE_DATA_VIDEO_ENCODER_RESOURCE_REQUIREMENTS req" && enable d3d12_encoder_feature
68246825 check_type "windows.h" "DPI_AWARENESS_CONTEXT" -D_WIN32_WINNT=0x0A00
6826+check_type "windows.h security.h schnlsp.h" SecPkgContext_KeyingMaterialInfo -DSECURITY_WIN32
68256827 check_type "d3d9.h dxva2api.h" DXVA2_ConfigPictureDecode -D_WIN32_WINNT=0x0602
68266828 check_func_headers mfapi.h MFCreateAlignedMemoryBuffer -lmfplat
68276829
@@ -7271,6 +7273,8 @@ enabled schannel && · 443 unmodified lines
72717273 schannel_extralibs="-lsecur32 -lncrypt -lcrypt32" ||
72727274 disable schannel
72737275
7276+enabled schannel && check_cc dtls_protocol "windows.h security.h schnlsp.h" "int i = SP_PROT_DTLS1_X_CLIENT;" -DSECURITY_WIN32
7277+
72747278 makeinfo --version > /dev/null 2>&1 && enable makeinfo || disable makeinfo
72757279 enabled makeinfo \
72767280 && [ 0$(makeinfo --version | grep "texinfo" | sed 's/.*texinfo[^0-9]*\([0-9]*\)\..*/\1/') -ge 5 ] \
libavformat/tls_schannel.c+31−2
@@ -20,6 +20,9 @@ · 19 unmodified lines
2020
2121 /** Based on the CURL SChannel module */
2222
23+#include "config.h"
24+#include "config_components.h"
25+
2326 #include "libavutil/mem.h"
2427 #include "avformat.h"
2528 #include "internal.h"
@@ -634,6 +637,7 @@ int ff_tls_set_external_socket(URLContext *h, URLContext *sock) · 608 unmodified lines
634637
635638 int ff_dtls_export_materials(URLContext *h, char *dtls_srtp_materials, size_t materials_sz)
636639 {
640+#if HAVE_SECPKGCONTEXT_KEYINGMATERIALINFO
637641 TLSContext *c = h->priv_data;
638642
639643 SecPkgContext_KeyingMaterialInfo keying_info = { 0 };
@@ -672,6 +676,9 @@ int ff_dtls_export_materials(URLContext *h, char *dtls_srtp_materials, size_t ma · 32 unmodified lines
672676 }
673677
674678 return 0;
679+#else
680+ return AVERROR(ENOSYS);
681+#endif
675682 }
676683
677684 int ff_dtls_state(URLContext *h)
@@ -773,7 +780,11 @@ static int tls_shutdown_client(URLContext *h) · 95 unmodified lines
773780 }
774781 FreeContextBuffer(outbuf.pvBuffer);
775782 }
776− } while(sspi_ret == SEC_I_MESSAGE_FRAGMENT || sspi_ret == SEC_I_CONTINUE_NEEDED);
783+ } while(
784+#ifdef SEC_I_MESSAGE_FRAGMENT
785+ sspi_ret == SEC_I_MESSAGE_FRAGMENT ||
786+#endif
787+ sspi_ret == SEC_I_CONTINUE_NEEDED);
777788
778789 av_log(h, AV_LOG_DEBUG, "Close session result: 0x%lx\n", sspi_ret);
779790
@@ -928,7 +939,11 @@ static int tls_handshake_loop(URLContext *h, int initial) · 148 unmodified lines
928939 }
929940
930941 /* continue handshake */
931− if (sspi_ret == SEC_I_CONTINUE_NEEDED || sspi_ret == SEC_I_MESSAGE_FRAGMENT || sspi_ret == SEC_E_OK) {
942+ if (sspi_ret == SEC_I_CONTINUE_NEEDED ||
943+#ifdef SEC_I_MESSAGE_FRAGMENT
944+ sspi_ret == SEC_I_MESSAGE_FRAGMENT ||
945+#endif
946+ sspi_ret == SEC_E_OK) {
932947 for (i = 0; i < 3; i++) {
933948 if (outbuf[i].BufferType == SECBUFFER_TOKEN && outbuf[i].cbBuffer > 0) {
934949 ret = ffurl_write(uc, outbuf[i].pvBuffer, outbuf[i].cbBuffer);
@@ -953,11 +968,13 @@ static int tls_handshake_loop(URLContext *h, int initial) · 18 unmodified lines
953968 goto fail;
954969 }
955970
971+#ifdef SEC_I_MESSAGE_FRAGMENT
956972 if (sspi_ret == SEC_I_MESSAGE_FRAGMENT) {
957973 av_log(h, AV_LOG_TRACE, "Writing fragmented output message part\n");
958974 read_data = 0;
959975 continue;
960976 }
977+#endif
961978
962979 if (inbuf[1].BufferType == SECBUFFER_EXTRA && inbuf[1].cbBuffer > 0) {
963980 if (c->enc_buf_offset > inbuf[1].cbBuffer) {
@@ -1080,6 +1097,7 @@ static int tls_handshake(URLContext *h) · 116 unmodified lines
10801097 if (ret < 0)
10811098 goto fail;
10821099
1100+#if CONFIG_DTLS_PROTOCOL
10831101 if (s->is_dtls && s->mtu > 0) {
10841102 ULONG mtu = s->mtu;
10851103 sspi_ret = SetContextAttributes(&c->ctxt_handle, SECPKG_ATTR_DTLS_MTU, &mtu, sizeof(mtu));
@@ -1090,6 +1108,7 @@ static int tls_handshake(URLContext *h) · 4 unmodified lines
10901108 }
10911109 av_log(h, AV_LOG_VERBOSE, "Set DTLS MTU to %d\n", s->mtu);
10921110 }
1111+#endif
10931112
10941113 c->connected = 1;
10951114 s->state = DTLS_STATE_FINISHED;
@@ -1136,8 +1155,10 @@ static int tls_open(URLContext *h, const char *uri, int flags, AVDictionary **op · 40 unmodified lines
11361155
11371156 schannel_cred.dwFlags = SCH_CRED_NO_SYSTEM_MAPPER | SCH_CRED_MANUAL_CRED_VALIDATION;
11381157
1158+#if CONFIG_DTLS_PROTOCOL
11391159 if (s->is_dtls)
11401160 schannel_cred.grbitEnabledProtocols = SP_PROT_DTLS1_X_SERVER;
1161+#endif
11411162 } else {
11421163 if (s->verify)
11431164 schannel_cred.dwFlags = SCH_CRED_AUTO_CRED_VALIDATION |
@@ -1147,8 +1168,10 @@ static int tls_open(URLContext *h, const char *uri, int flags, AVDictionary **op · 3 unmodified lines
11471168 SCH_CRED_IGNORE_NO_REVOCATION_CHECK |
11481169 SCH_CRED_IGNORE_REVOCATION_OFFLINE;
11491170
1171+#if CONFIG_DTLS_PROTOCOL
11501172 if (s->is_dtls)
11511173 schannel_cred.grbitEnabledProtocols = SP_PROT_DTLS1_X_CLIENT;
1174+#endif
11521175 }
11531176
11541177 /* Get credential handle */
@@ -1183,6 +1206,7 @@ end: · 28 unmodified lines
11831206 return ret;
11841207 }
11851208
1209+#if CONFIG_DTLS_PROTOCOL
11861210 static int dtls_open(URLContext *h, const char *uri, int flags, AVDictionary **options)
11871211 {
11881212 TLSContext *c = h->priv_data;
@@ -1192,6 +1216,7 @@ static int dtls_open(URLContext *h, const char *uri, int flags, AVDictionary **o · 3 unmodified lines
11921216
11931217 return tls_open(h, uri, flags, options);
11941218 }
1219+#endif
11951220
11961221 static int tls_read(URLContext *h, uint8_t *buf, int len)
11971222 {
@@ -1439,6 +1464,7 @@ static const AVOption options[] = { · 241 unmodified lines
14391464 { NULL }
14401465 };
14411466
1467+#if CONFIG_TLS_PROTOCOL
14421468 static const AVClass tls_class = {
14431469 .class_name = "tls",
14441470 .item_name = av_default_item_name,
@@ -1458,7 +1484,9 @@ const URLProtocol ff_tls_protocol = { · 13 unmodified lines
14581484 .flags = URL_PROTOCOL_FLAG_NETWORK,
14591485 .priv_data_class = &tls_class,
14601486 };
1487+#endif
14611488
1489+#if CONFIG_DTLS_PROTOCOL
14621490 static const AVClass dtls_class = {
14631491 .class_name = "dtls",
14641492 .item_name = av_default_item_name,
@@ -1479,3 +1507,4 @@ const URLProtocol ff_dtls_protocol = { · 14 unmodified lines
14791507 .flags = URL_PROTOCOL_FLAG_NETWORK,
14801508 .priv_data_class = &dtls_class,
14811509 };
1510+#endif

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t