Skip to contentSkip to conversation

libsecret: retrieve empty password

PATCH Superseded M Hickford via GitGitGadget 3 participants 4 messages Feb 18, 2024 – Feb 19, 2024

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 libsecret: retrieve empty password

From: M Hickford <[email protected]>

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

---
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(+)
contrib/credential/libsecret/git-credential-libsecret.c +3 -0
index 215a81d8bae..d9e9e4fd524 100644
@@ -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

Signature · 1 line
gitgitgadget
#1 lore raw
Quoted 27 lines · M Hickford via GitGitGadget

From: M Hickford <[email protected]>

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

---
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(+)
contrib/credential/libsecret/git-credential-libsecret.c +0 -0
index 215a81d8bae..d9e9e4fd524 100644

contrib/credential/libsecret/git-credential-libsecret.c static int keyring_get(struct credential *c) · line 169

Quoted 6 lines
contrib/credential/libsecret/git-credential-libsecret.c +3 -0
@@ -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

Quoted 8 lines
contrib/credential/libsecret/git-credential-libsecret.c +0 -0
 			}
 			for (int i = 1; i < g_strv_length(parts); i++) {
 				if (g_str_has_prefix(parts[i], "password_expiry_utc=")) {

base-commit: 3e0d3cd5c7def4808247caf168e17f2bbf47892b

Signature · 1 line
gitgitgadget
#2 lore raw
Quoted 5 lines

contrib/credential/libsecret/git-credential-libsecret.c static int keyring_get(struct credential *c) · line 169

Quoted 2 lines
contrib/credential/libsecret/git-credential-libsecret.c +2 -0
+                             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.

#3 lore raw

PATCH v2 1/1 libsecret: retrieve empty password

In reply to M Hickford via GitGitGadget

From: M Hickford <[email protected]>

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

---
libsecret: retrieve empty password

cc Patrick Steinhardt [email protected]

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(+)
contrib/credential/libsecret/git-credential-libsecret.c +3 -0
index 215a81d8bae..90034d0cf1e 100644
@@ -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

Signature · 1 line
gitgitgadget