Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SMTP with GMail fails with out of memory error in 7.69.1 (works OK in 7.68.0) #5294

Closed
RMerl opened this issue Apr 24, 2020 · 8 comments
Closed
Labels

Comments

@RMerl
Copy link

@RMerl RMerl commented Apr 24, 2020

I did this

curl -s -S -4 -v --interface eth0 \
--ssl-reqd \
--url smtp://smtp.gmail.com:587 \
--mail-auth "user@gmail.com" \
--user "user@gmail.com:MyPassword" \
--mail-from "user@gmail.com" \
--mail-rcpt "user@gmail.com" \
--upload-file /jffs/mail.txt

I expected the following

After the early authentication bits, this is a successful session under 7.68.0:

(snip)
< 235 2.7.0 Accepted
} [5 bytes data]
> MAIL FROM:<user@gmail.com> AUTH=user@gmail.com SIZE=135
{ [5 bytes data]
< 250 2.1.0 OK i127sm4454764qkc.93 - gsmtp
} [5 bytes data]
> RCPT TO:<user@gmail.com>
{ [5 bytes data]
< 250 2.1.5 OK i127sm4454764qkc.93 - gsmtp
} [5 bytes data]
> DATA
{ [5 bytes data]
< 354  Go ahead i127sm4454764qkc.93 - gsmtp
} [5 bytes data]
* We are completely uploaded and fine
} [5 bytes data]
< 250 2.0.0 OK  1587760481 i127sm4454764qkc.93 - gsmtp
* Connection #0 to host smtp.gmail.com left intact

However with 7.69.1, it returns this:

(snip)
< 235 2.7.0 Accepted
} [5 bytes data]
> QUIT
{ [5 bytes data]
< 221 2.0.0 closing connection h13sm2593942qti.32 - gsmtp
* Closing connection 0
} [5 bytes data]
* TLSv1.2 (OUT), TLS alert, close notify (256):
} [2 bytes data]
curl: (27) Out of memory
  1. Instead of jumping into the MAIL FROM portion, it immediately issues QUIT
  2. As the process exits, it reports an Out of memory.

mail.txt contains a very short test file with a From, To,Date, and two lines of content.

This might be server-specific, as my own ISP's server seems to work fine with a similar request.

curl/libcurl version

curl 7.69.1 (arm-unknown-linux-gnu) libcurl/7.69.1 OpenSSL/1.0.2u
Release-Date: 2020-03-11
Protocols: file ftp ftps http https imap imaps pop3 pop3s smb smbs smtp smtps
Features: HTTPS-proxy IPv6 Largefile NTLM SSL TLS-SRP UnixSockets

operating system

Asuswrt-Merlin (Linux-based router firmware).

Tested both on an older uclibc+kernel 2.6.36 and on a glibc+kernel 4.1.51 kernel.

OpenSSL 1.0.2u is used for the SSL/TLS backend.

@bagder bagder added the SMTP label Apr 24, 2020
@RMerl
Copy link
Author

@RMerl RMerl commented Apr 24, 2020

I updated the reported OpenSSL version - I incorrectly specified OpenSSL 1.1.1, but I had forgotten that I have curl linked against 1.0.2u for technical reasons.

@RMerl
Copy link
Author

@RMerl RMerl commented Apr 24, 2020

Potential cause?

aeb2923#diff-65cc11e82be15630f137b0476644a46b

I will see if I can resolve the issue by reverting this change. BRB...

@RMerl
Copy link
Author

@RMerl RMerl commented Apr 24, 2020

Nope, that wasn't it. Will require more digging through changes between 7.68.0 and 7.69.1.

@bagder
Copy link
Member

@bagder bagder commented Apr 24, 2020

Maybe bisect? Or possibly single-step with a debugger to find which condition that is triggered.

@john9527
Copy link

@john9527 john9527 commented Apr 24, 2020

Maybe another possibility
2d137de

@RMerl
Copy link
Author

@RMerl RMerl commented Apr 24, 2020

Completed bisect, first bad commit is 68fb25f .

@jay
Copy link
Member

@jay jay commented Apr 24, 2020

Check your encoding

/cc @captain-caveman2k

@RMerl
Copy link
Author

@RMerl RMerl commented Apr 24, 2020

Issue tracked down and fixed here (been looking at it with bagder over IRC).

bagder added a commit that referenced this issue Apr 24, 2020
Regression since 7.69.0 and 68fb25f.

The code wrongly assigned 'from' instead of 'auth' which probably was a
copy and paste mistake from other code, leading to that auth could
remain NULL and later cause an error to be returned.

Assisted-by: Eric Sauvageau
Fixes #5294
@bagder bagder closed this in 446fb05 Apr 25, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

4 participants
You can’t perform that action at this time.