Skip to content

Commit 0f8ecc1

Browse files
committed
libjob: fix leak, improve error from unwrap_string()
Problem: When built with flux-security support, unwrap_string() leaks the security context object when flux_security_create() succeeds, but flux_security_configure() fails. Also, the error message is generic so the specific error from flux_security_configure() available from flux_security_last_error() is suppressed. Fix these two issues by handling failure from flux_security_configure() separately from flux_security_create().
1 parent 9f960a3 commit 0f8ecc1

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

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)