]> git.ipfire.org Git - thirdparty/git.git/commit
gpg-interface: do not use misdesigned strbuf_split*()
authorOlamide Caleb Bello <belkid98@gmail.com>
Thu, 23 Oct 2025 11:13:46 +0000 (11:13 +0000)
committerJunio C Hamano <gitster@pobox.com>
Thu, 23 Oct 2025 16:26:12 +0000 (09:26 -0700)
commitbee1bdd5888aafd1a8d51df000170f18b6a299ac
treeffbcb9666b726ded301d0523237e4fed358d25b4
parent81f86aacc4eb74cdb9c2c8082d36d2070c666045
gpg-interface: do not use misdesigned strbuf_split*()

In get_ssh_finger_print(), the output of the `ssh-keygen` command is
put into `fingerprint_stdout` strbuf. The string in `fingerprint_stdout`
is then split into up to 3 strbufs using strbuf_split_max(). However they
are not modified after the split thereby not making use of the strbuf API
as the fingerprint token is merely returned as a char * and not a strbuf.
Hence they do not need to be strbufs.

Simplify the process of retrieving and returning the desired token by
using strchr() to isolate the token and xmemdupz() to return a copy of the
token. This removes the roundabout way of splitting the string into
strbufs just to return the token.

Reported-by: Junio Hamano <gitster@pobox.com>
Helped-by: Christian Couder <christian.couder@gmail.com>
Helped-by: Kristoffer Haugsbakk <kristofferhaugsbakk@fastmail.com>
Signed-off-by: Olamide Caleb Bello <belkid98@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
gpg-interface.c