Skip to content

Commit 85eaaa9

Browse files
authored
Merge pull request #6204 from chu11/kvs_strtoul_cleanup
kvs: correct transaction-merge option parsing
2 parents 6c3db5c + 49ce438 commit 85eaaa9

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

src/modules/kvs/kvs.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2852,8 +2852,15 @@ static int process_args (struct kvs_ctx *ctx, int ac, char **av)
28522852
int i;
28532853

28542854
for (i = 0; i < ac; i++) {
2855-
if (strstarts (av[i], "transaction-merge="))
2856-
ctx->transaction_merge = strtoul (av[i]+13, NULL, 10);
2855+
if (strstarts (av[i], "transaction-merge=")) {
2856+
char *endptr;
2857+
errno = 0;
2858+
ctx->transaction_merge = strtoul (av[i]+18, &endptr, 10);
2859+
if (errno != 0 || *endptr != '\0') {
2860+
errno = EINVAL;
2861+
return -1;
2862+
}
2863+
}
28572864
else {
28582865
flux_log (ctx->h, LOG_ERR, "Unknown option `%s'", av[i]);
28592866
errno = EINVAL;

t/t1000-kvs.t

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1291,4 +1291,8 @@ test_expect_success 'module fails to load with unknown option' '
12911291
test_must_fail flux module load kvs badopt
12921292
'
12931293

1294+
test_expect_success 'module fails to load with bad input to transaction-merge' '
1295+
test_must_fail flux module reload kvs transaction-merge=foobar
1296+
'
1297+
12941298
test_done

0 commit comments

Comments
 (0)