bug-wget
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug-wget] stderr file descriptor bug in wget


From: Jason Tyler
Subject: [Bug-wget] stderr file descriptor bug in wget
Date: Thu, 12 Sep 2019 11:52:02 +1000

Tested all the way up to wget-1.20.3:

I noticed that I was getting different results from these two commands:

wget -O- www.server.com.au/index.html 2>/dev/null

wget -O- www.server.com.au/index.html 2>&-

This turned out to be because, when file descriptor 2 has been closed, wget
opens a socket to the webserver which becomes file descriptor 2 since
that's the first unused FD.

wget then sends both its HTTP traffic _and_ the stuff it would normally
send to standard error to this network socket. (Which is why adding
"--quiet" corrects the behaviour for the second command above.)

Looks like the code is somehow doing a write(2,...) regardless of whether
this is really standard error.

Sample tcpdump output, showing that "HTTP request sent, awaiting response"
gets written to the webserver:


11:41:59.797549 IP (tos 0x0, ttl 64, id 29147, offset 0, flags [DF], proto
TCP (6), length 251)
  jpt.domain.com.au.36822 > 27.96.202.231.http: Flags [P.], cksum 0x04d5
(incorrect -> 0xa914), seq 12:211, ack 1, win 502, options [nop,nop,TS val
1550480171 ecr 3856601808], length 199: HTTP, length: 199
        GET /index.html HTTP/1.1
        User-Agent: Wget/1.20.1 (linux-gnu)
        Accept: */*
        Accept-Encoding: identity
        Host: www.pulsemining.com.au
        Connection: Keep-Alive

*        HTTP request sent, awaiting response... [!http]   <<<<<< HERE*
11:41:59.812221 IP (tos 0x0, ttl 50, id 31586, offset 0, flags [DF], proto
TCP (6), length 52)


Jason


reply via email to

[Prev in Thread] Current Thread [Next in Thread]