git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [PATCH] libsecret: retrieve empty password
@ 2024-02-18 22:51 M Hickford via GitGitGadget
  2024-02-19  6:08 ` Patrick Steinhardt
  2024-02-19 20:40 ` [PATCH v2] " M Hickford via GitGitGadget
  0 siblings, 2 replies; 4+ messages in thread
From: M Hickford via GitGitGadget @ 2024-02-18 22:51 UTC (permalink / raw
  To: git; +Cc: M Hickford, M Hickford

From: M Hickford <mirth.hickford@gmail.com>

Since 0ce02e2f (credential/libsecret: store new attributes, 2023-06-16)
a test that stores empty username and password fails when
t0303-credential-external.sh is run with
GIT_TEST_CREDENTIAL_HELPER=libsecret.

Retrieve empty password carefully. This fixes test:

    ok 14 - helper (libsecret) can store empty username

Signed-off-by: M Hickford <mirth.hickford@gmail.com>
---
    libsecret: retrieve empty password

Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-1676%2Fhickford%2Flibsecret-empty-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-1676/hickford/libsecret-empty-v1
Pull-Request: https://github.com/git/git/pull/1676

 contrib/credential/libsecret/git-credential-libsecret.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/contrib/credential/libsecret/git-credential-libsecret.c b/contrib/credential/libsecret/git-credential-libsecret.c
index 215a81d8bae..d9e9e4fd524 100644
--- a/contrib/credential/libsecret/git-credential-libsecret.c
+++ b/contrib/credential/libsecret/git-credential-libsecret.c
@@ -164,6 +164,9 @@ static int keyring_get(struct credential *c)
 			if (g_strv_length(parts) >= 1) {
 				g_free(c->password);
 				c->password = g_strdup(parts[0]);
+			} else {
+				g_free(c->password);
+				c->password = strdup("");
 			}
 			for (int i = 1; i < g_strv_length(parts); i++) {
 				if (g_str_has_prefix(parts[i], "password_expiry_utc=")) {

base-commit: 3e0d3cd5c7def4808247caf168e17f2bbf47892b
-- 
gitgitgadget


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] libsecret: retrieve empty password
  2024-02-18 22:51 [PATCH] libsecret: retrieve empty password M Hickford via GitGitGadget
@ 2024-02-19  6:08 ` Patrick Steinhardt
  2024-02-19 20:00   ` M Hickford
  2024-02-19 20:40 ` [PATCH v2] " M Hickford via GitGitGadget
  1 sibling, 1 reply; 4+ messages in thread
From: Patrick Steinhardt @ 2024-02-19  6:08 UTC (permalink / raw
  To: M Hickford via GitGitGadget; +Cc: git, M Hickford

[-- Attachment #1: Type: text/plain, Size: 1849 bytes --]

On Sun, Feb 18, 2024 at 10:51:34PM +0000, M Hickford via GitGitGadget wrote:
> From: M Hickford <mirth.hickford@gmail.com>
> 
> Since 0ce02e2f (credential/libsecret: store new attributes, 2023-06-16)
> a test that stores empty username and password fails when
> t0303-credential-external.sh is run with
> GIT_TEST_CREDENTIAL_HELPER=libsecret.
> 
> Retrieve empty password carefully. This fixes test:
> 
>     ok 14 - helper (libsecret) can store empty username
> 
> Signed-off-by: M Hickford <mirth.hickford@gmail.com>
> ---
>     libsecret: retrieve empty password
> 
> Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-1676%2Fhickford%2Flibsecret-empty-v1
> Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-1676/hickford/libsecret-empty-v1
> Pull-Request: https://github.com/git/git/pull/1676
> 
>  contrib/credential/libsecret/git-credential-libsecret.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/contrib/credential/libsecret/git-credential-libsecret.c b/contrib/credential/libsecret/git-credential-libsecret.c
> index 215a81d8bae..d9e9e4fd524 100644
> --- a/contrib/credential/libsecret/git-credential-libsecret.c
> +++ b/contrib/credential/libsecret/git-credential-libsecret.c
> @@ -164,6 +164,9 @@ static int keyring_get(struct credential *c)
>  			if (g_strv_length(parts) >= 1) {
>  				g_free(c->password);
>  				c->password = g_strdup(parts[0]);
> +			} else {
> +				g_free(c->password);
> +				c->password = strdup("");

Shouldn't we use `g_strdup()` here, like we do everywhere else in this
credential helper?

Patrick

>  			}
>  			for (int i = 1; i < g_strv_length(parts); i++) {
>  				if (g_str_has_prefix(parts[i], "password_expiry_utc=")) {
> 
> base-commit: 3e0d3cd5c7def4808247caf168e17f2bbf47892b
> -- 
> gitgitgadget
> 

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] libsecret: retrieve empty password
  2024-02-19  6:08 ` Patrick Steinhardt
@ 2024-02-19 20:00   ` M Hickford
  0 siblings, 0 replies; 4+ messages in thread
From: M Hickford @ 2024-02-19 20:00 UTC (permalink / raw
  To: Patrick Steinhardt; +Cc: M Hickford via GitGitGadget, git, M Hickford

> > +                             g_free(c->password);
> > +                             c->password = strdup("");
>
> Shouldn't we use `g_strdup()` here, like we do everywhere else in this
> credential helper?

You're right. I'll correct in patch v2.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH v2] libsecret: retrieve empty password
  2024-02-18 22:51 [PATCH] libsecret: retrieve empty password M Hickford via GitGitGadget
  2024-02-19  6:08 ` Patrick Steinhardt
@ 2024-02-19 20:40 ` M Hickford via GitGitGadget
  1 sibling, 0 replies; 4+ messages in thread
From: M Hickford via GitGitGadget @ 2024-02-19 20:40 UTC (permalink / raw
  To: git; +Cc: M Hickford, M Hickford

From: M Hickford <mirth.hickford@gmail.com>

Since 0ce02e2f (credential/libsecret: store new attributes, 2023-06-16)
a test that stores empty username and password fails when
t0303-credential-external.sh is run with
GIT_TEST_CREDENTIAL_HELPER=libsecret.

Retrieve empty password carefully. This fixes test:

    ok 14 - helper (libsecret) can store empty username

Signed-off-by: M Hickford <mirth.hickford@gmail.com>
---
    libsecret: retrieve empty password
    
    cc: Patrick Steinhardt ps@pks.im

Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-1676%2Fhickford%2Flibsecret-empty-v2
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-1676/hickford/libsecret-empty-v2
Pull-Request: https://github.com/git/git/pull/1676

Range-diff vs v1:

 1:  877bbfb72ed ! 1:  2cdcba20622 libsecret: retrieve empty password
     @@ contrib/credential/libsecret/git-credential-libsecret.c: static int keyring_get(
       				c->password = g_strdup(parts[0]);
      +			} else {
      +				g_free(c->password);
     -+				c->password = strdup("");
     ++				c->password = g_strdup("");
       			}
       			for (int i = 1; i < g_strv_length(parts); i++) {
       				if (g_str_has_prefix(parts[i], "password_expiry_utc=")) {


 contrib/credential/libsecret/git-credential-libsecret.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/contrib/credential/libsecret/git-credential-libsecret.c b/contrib/credential/libsecret/git-credential-libsecret.c
index 215a81d8bae..90034d0cf1e 100644
--- a/contrib/credential/libsecret/git-credential-libsecret.c
+++ b/contrib/credential/libsecret/git-credential-libsecret.c
@@ -164,6 +164,9 @@ static int keyring_get(struct credential *c)
 			if (g_strv_length(parts) >= 1) {
 				g_free(c->password);
 				c->password = g_strdup(parts[0]);
+			} else {
+				g_free(c->password);
+				c->password = g_strdup("");
 			}
 			for (int i = 1; i < g_strv_length(parts); i++) {
 				if (g_str_has_prefix(parts[i], "password_expiry_utc=")) {

base-commit: 3e0d3cd5c7def4808247caf168e17f2bbf47892b
-- 
gitgitgadget


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-02-19 20:41 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-02-18 22:51 [PATCH] libsecret: retrieve empty password M Hickford via GitGitGadget
2024-02-19  6:08 ` Patrick Steinhardt
2024-02-19 20:00   ` M Hickford
2024-02-19 20:40 ` [PATCH v2] " M Hickford via GitGitGadget

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).