Skip to content

Commit ade38ce

Browse files
authored
Merge pull request #5248 from grondo/sign_unwrap-leak
libjob: fix leak in sign_unwrap()
2 parents 9f960a3 + 8ef6ae4 commit ade38ce

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

src/common/libjob/test/unwrap.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,16 @@ static void test_api (unwrap_f unwrap)
4747
"error.text says: %s",
4848
error.text);
4949

50+
userid = 0;
51+
result = (*unwrap) (s, false, NULL, &error);
52+
ok (result != NULL && userid == 0,
53+
"unwrap_string() works with NULL userid");
54+
if (result == NULL)
55+
diag ("got error: %s", error.text);
56+
is (result, "bar",
57+
"got expected result");
58+
free (result);
59+
5060
userid = 0;
5161
result = (*unwrap) (s, false, NULL, NULL);
5262
ok (result != NULL && userid == 0,

src/common/libjob/unwrap.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,16 @@ char *unwrap_string (const char *s,
7676
int64_t userid64;
7777
int flags = verify ? 0 : FLUX_SIGN_NOVERIFY;
7878

79-
if (!(sec = flux_security_create (0))
80-
|| flux_security_configure (sec, NULL) < 0) {
79+
if (!(sec = flux_security_create (0))) {
8180
errprintf (errp,
82-
"failed to initialize security context: %s",
81+
"failed to create security context: %s",
8382
strerror (errno));
84-
return NULL;
83+
}
84+
if (flux_security_configure (sec, NULL) < 0) {
85+
errprintf (errp,
86+
"failed to configure security context: %s",
87+
flux_security_last_error (sec));
88+
goto done;
8589
}
8690
if (flux_sign_unwrap_anymech (sec,
8791
s,

0 commit comments

Comments
 (0)