git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] git-send-email.perl: avoid printing undef when validating addresses

From
Jeff King <peff@peff.net>
Date
Sep 18, 2023, 21:20 UTC
Message-ID
<20230918212004.GC2163162@coredump.intra.peff.net>
In-Reply-To
<545729b619308c6f3397b9aa1747f26ddc58f461.1695054945.git.me@ttaylorr.com>
On Mon, Sep 18, 2023 at 12:35:53PM -0400, Taylor Blau wrote:
Show 16 quoted lines
> When validating email addresses with `extract_valid_address_or_die()`,
> we print out a helpful error message when the given input does not
> contain a valid email address.
> 
> However, the pre-image of this patch looks something like:
> 
>     my $address = shift;
>     $address = extract_valid_address($address):
>     die sprintf(__("..."), $address) if !$address;
> 
> which fails when given a bogus email address by trying to use $address
> (which is undef) in a sprintf() expansion, like so:
> 
>     $ git.compile send-email --to="pi <pi@pi>" /tmp/x/*.patch --force
>     Use of uninitialized value $address in sprintf at /home/ttaylorr/src/git/git-send-email line 1175.
>     error: unable to extract a valid address from:

Yeah, we overwrite the variable we're reporting on, so I don't think the original could possibly work. Your fix makes sense.

Show 5 quoted lines
> This regression dates back to e431225569 (git-send-email: remove invalid
> addresses earlier, 2012-11-22), but became more noticeable in a8022c5f7b
> (send-email: expose header information to git-send-email's
> sendemail-validate hook, 2023-04-19), which validates SMTP headers in
> the sendemail-validate hook.

I didn't quite understand how a8022c5f7b made this worse, but I guess we just call it the bad function in more instances. The bug is definitely from e431225569, though.

-Peff
Previous: Junio C HamanoNext: Michael Strawbridge
Message 4 of 15 in “[REGRESSION] uninitialized value $address in git send-email”
  1. Bagas SanjayaSep 18, 2023
  2. git-send-email.perl: avoid printing undef when validating addressesTaylor Blau, Sep 18, 2023
  3. Junio C HamanoSep 18, 2023
  4. Jeff KingSep 18, 2023
  5. Michael StrawbridgeSep 18, 2023
  6. Bagas SanjayaSep 19, 2023
  7. Michael StrawbridgeSep 19, 2023
  8. Michael StrawbridgeSep 19, 2023
  9. Bagas SanjayaSep 20, 2023
  10. Michael StrawbridgeSep 20, 2023
  11. Junio C HamanoSep 20, 2023
  12. Bagas SanjayaSep 21, 2023
  13. Junio C HamanoSep 21, 2023
  14. Bagas SanjayaSep 22, 2023
  15. Junio C HamanoSep 20, 2023

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.