[FFmpeg-trac] #10215(ffmpeg:new): Windows tcp: Starting connection attempt to <GARBAGE> port <GARBAGE>

FFmpeg trac at avcodec.org
Mon Feb 27 20:11:05 EET 2023


#10215: Windows tcp: Starting connection attempt to <GARBAGE> port <GARBAGE>
-------------------------------------+----------------------------------
             Reporter:  Korl         |                    Owner:  (none)
                 Type:  defect       |                   Status:  new
             Priority:  normal       |                Component:  ffmpeg
              Version:  unspecified  |               Resolution:
             Keywords:               |               Blocked By:
             Blocking:               |  Reproduced by developer:  0
Analyzed by developer:  0            |
-------------------------------------+----------------------------------

Old description:

> Saving RTSP stream from a chinese camera to disk with
>
> {{{
> C:\app\ffmpeg-5.1.2-full_build\bin\ffmpeg.exe -hide_banner
> -rtsp_transport tcp -i "rtsp://192.168.4.15:8754/11" -c copy
> "C:\ffmpeg_test\rec.mkv" -y -nostdin -loglevel debug
> }}}
>
> works well and produces the following log
>

> {{{
> [tcp @ 000002405c964000] No default whitelist set
> [tcp @ 000002405c964000] Original list of addresses:
> [tcp @ 000002405c964000] Address 192.168.4.15 port 8754
> [tcp @ 000002405c964000] Interleaved list of addresses:
> [tcp @ 000002405c964000] Address 192.168.4.15 port 8754
> [tcp @ 000002405c964000] Starting connection attempt to 192.168.4.15 port
> 8754
> [tcp @ 000002405c964000] Successfully connected to 192.168.4.15 port 8754
> }}}
>

> putting this same command line in a batch file and run it as service
>

> {{{
> sc create "cam_save" start= demand displayname= "cam_save" binpath=
> ""C:\App\svcbatch-1.4.0-win-x64\svcbatch.exe"
> C:\ffmpeg_test\batch_to_run.bat"
> }}}
>
> fails with
>

> {{{
> [tcp @ 000001cd0c777b80] No default whitelist set
> [tcp @ 000001cd0c777b80] Original list of addresses:
> [tcp @ 000001cd0c777b80] Address  ˘ź< port ÷{w
Í?
> [tcp @ 000001cd0c777b80] Interleaved list of addresses:
> [tcp @ 000001cd0c777b80] Address  ˘ź< port ÷{w
Í?
> [tcp @ 000001cd0c777b80] Starting connection attempt to  ˘ź< port "2ü
Í?
> [tcp @ 000001cd0c777b80] Connected attempt failed: Error number -10106
> occurred
> [tcp @ 000001cd0c777b80] Connection to tcp://192.168.4.15:8754?timeout=0
> failed: Error number -10106 occurred
> rtsp://192.168.4.15:8754/11: Unknown error
> }}}
>

> I'm guessing it is a security issue with windows services (don't know
> which) but I guess the garbage displayed is a memory leak.
>
> Reproduced on two different PC's with windows builds taken from Gyan and
> BtbN 5.x and 4.x

New description:

 Saving RTSP stream from a chinese camera to disk with

 {{{
 C:\app\ffmpeg-5.1.2-full_build\bin\ffmpeg.exe -hide_banner -rtsp_transport
 tcp -i "rtsp://192.168.4.15:8754/11" -c copy "C:\ffmpeg_test\rec.mkv" -y
 -nostdin -loglevel debug
 }}}

 works well and produces the following log


 {{{
 [tcp @ 000002405c964000] No default whitelist set
 [tcp @ 000002405c964000] Original list of addresses:
 [tcp @ 000002405c964000] Address 192.168.4.15 port 8754
 [tcp @ 000002405c964000] Interleaved list of addresses:
 [tcp @ 000002405c964000] Address 192.168.4.15 port 8754
 [tcp @ 000002405c964000] Starting connection attempt to 192.168.4.15 port
 8754
 [tcp @ 000002405c964000] Successfully connected to 192.168.4.15 port 8754
 }}}


 putting this same command line in a batch file and run it as service


 {{{
 sc create "cam_save" start= demand displayname= "cam_save" binpath=
 ""C:\App\svcbatch-1.4.0-win-x64\svcbatch.exe"
 C:\ffmpeg_test\batch_to_run.bat"
 }}}

 fails with


 {{{
 [tcp @ 000001cd0c777b80] No default whitelist set
 [tcp @ 000001cd0c777b80] Original list of addresses:
 [tcp @ 000001cd0c777b80] Address  ˘ź< port ÷{wÍ?
 [tcp @ 000001cd0c777b80] Interleaved list of addresses:
 [tcp @ 000001cd0c777b80] Address  ˘ź< port ÷{wÍ?
 [tcp @ 000001cd0c777b80] Starting connection attempt to  ˘ź< port "2üÍ?
 [tcp @ 000001cd0c777b80] Connected attempt failed: Error number -10106
 occurred
 [tcp @ 000001cd0c777b80] Connection to tcp://192.168.4.15:8754?timeout=0
 failed: Error number -10106 occurred
 rtsp://192.168.4.15:8754/11: Unknown error
 }}}


 I'm guessing it is a security issue with windows services (don't know
 which) but I guess the garbage displayed is a memory leak.

 Reproduced on two different PC's with windows builds taken from Gyan and
 BtbN 5.x and 4.x

--
Comment (by Korl):

 I found out that this case appears if %SystemRoot% is not defined.
 msock.dll cannot be loaded and none of the socket functions work.

 in file libavformat/network.c

 {{{
             getnameinfo(addrs->ai_addr, addrs->ai_addrlen,
                         hostbuf, sizeof(hostbuf), portbuf,
 sizeof(portbuf),
                         NI_NUMERICHOST | NI_NUMERICSERV);
             av_log(h, AV_LOG_VERBOSE, "Starting connection attempt to %s
 port %s\n",
                                       hostbuf, portbuf);
             last_err = start_connect_attempt(&attempts[nb_attempts],
 &addrs,
                                              timeout_ms_per_address, h,
                                              customize_fd, customize_ctx);

 }}}

 result of getnameinfo() should be checked before continuing.
-- 
Ticket URL: <https://trac.ffmpeg.org/ticket/10215#comment:1>
FFmpeg <https://ffmpeg.org>
FFmpeg issue tracker


More information about the FFmpeg-trac mailing list