Skip to content

Commit 2b4eeac

Browse files
committed
shell: fix incorrect prefix of shell_mustache_render(3)
Problem: The shell_mustache_render(3) function is not prefixed with flux_, so the symbol is not exported dynamically to external shell plugins. Rename shell_mustache_render(3) to flux_shell_mustache_render(3). Add check for shell == NULL and return EINVAL instead of crashing with NULL deref.
1 parent 1e66f16 commit 2b4eeac

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

src/shell/output.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -814,7 +814,7 @@ shell_output_setup_type_file (struct shell_output *out,
814814
return -1;
815815
}
816816

817-
if (!(ofp->path = shell_mustache_render (out->shell, path)))
817+
if (!(ofp->path = flux_shell_mustache_render (out->shell, path)))
818818
return -1;
819819

820820
if (flux_shell_getopt_unpack (out->shell, "output",

src/shell/shell.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -980,8 +980,13 @@ static int get_protocol_fd (int *pfd)
980980
return 0;
981981
}
982982

983-
char *shell_mustache_render (flux_shell_t *shell, const char *fmt)
983+
char *flux_shell_mustache_render (flux_shell_t *shell, const char *fmt)
984984
{
985+
if (!shell) {
986+
/* Note: shell->mr and fmt checked in mustache_render */
987+
errno = EINVAL;
988+
return NULL;
989+
}
985990
return mustache_render (shell->mr, fmt);
986991
}
987992

@@ -1537,7 +1542,8 @@ static int frob_command (flux_shell_t *shell, flux_cmd_t *cmd)
15371542
for (int i = 0; i < flux_cmd_argc (cmd); i++) {
15381543
if (strstr (flux_cmd_arg (cmd, i), "{{")) { // possibly mustachioed
15391544
char *narg;
1540-
if (!(narg = shell_mustache_render (shell, flux_cmd_arg (cmd, i)))
1545+
if (!(narg = flux_shell_mustache_render (shell,
1546+
flux_cmd_arg (cmd, i)))
15411547
|| flux_cmd_argv_insert (cmd, i, narg) < 0) {
15421548
free (narg);
15431549
return -1;

src/shell/shell.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,7 @@ int flux_shell_log_setlevel (int level, const char *dest);
403403

404404
/* Expand mustache template. Caller must free the result.
405405
*/
406-
char *shell_mustache_render (flux_shell_t *shell, const char *fmt);
406+
char *flux_shell_mustache_render (flux_shell_t *shell, const char *fmt);
407407

408408

409409
#ifdef __cplusplus

0 commit comments

Comments
 (0)