From 87fdd3bb91096204bf826548f583f58259dd46cf Mon Sep 17 00:00:00 2001 From: David Teigland Date: Mar 22 2022 19:24:46 +0000 Subject: sanlock: acquire should ignore unused options str If the caller sets and sends opt len/str, the daemon will receive it but do nothing with it. --- diff --git a/src/client.c b/src/client.c index 5dc7650..f8d7d64 100644 --- a/src/client.c +++ b/src/client.c @@ -1140,7 +1140,8 @@ int sanlock_acquire(int sock, int pid, uint32_t flags, int res_count, datalen += sizeof(struct sanlk_options); if (opt_in) { memcpy(&opt, opt_in, sizeof(struct sanlk_options)); - datalen += opt_in->len; + /* data beyond opt is not used */ + /* datalen += opt_in->len; */ } else { memset(&opt, 0, sizeof(opt)); } @@ -1187,6 +1188,7 @@ int sanlock_acquire(int sock, int pid, uint32_t flags, int res_count, goto out; } + /* if (opt.len) { rv = send_data(fd, opt_in->str, opt.len, 0); if (rv < 0) { @@ -1194,6 +1196,7 @@ int sanlock_acquire(int sock, int pid, uint32_t flags, int res_count, goto out; } } + */ rv = recv_result(fd); out: diff --git a/src/cmd.c b/src/cmd.c index 6815585..3067e3e 100644 --- a/src/cmd.c +++ b/src/cmd.c @@ -199,7 +199,6 @@ static void cmd_acquire(struct task *task, struct cmd_args *ca, uint32_t cmd) struct space_info spi; char killpath[SANLK_HELPER_PATH_LEN]; char killargs[SANLK_HELPER_ARGS_LEN]; - char *opt_str; int token_len, disks_len; int fd, rv, i, j, empty_slots, lvl; int alloc_count = 0, acquire_count = 0; @@ -361,6 +360,8 @@ static void cmd_acquire(struct task *task, struct cmd_args *ca, uint32_t cmd) strncpy(cl->owner_name, opt.owner_name, SANLK_NAME_LEN); + /* data after opt is not used */ + /* if (opt.len) { opt_str = malloc(opt.len); if (!opt_str) { @@ -379,6 +380,7 @@ static void cmd_acquire(struct task *task, struct cmd_args *ca, uint32_t cmd) goto done; } } + */ /* TODO: warn if header.length != sizeof(header) + pos ? */ recv_done = 1; diff --git a/src/sanlock.h b/src/sanlock.h index e9a5ec4..5999630 100644 --- a/src/sanlock.h +++ b/src/sanlock.h @@ -137,8 +137,8 @@ struct sanlk_rentry { struct sanlk_options { char owner_name[SANLK_NAME_LEN]; /* optional user friendly name */ uint32_t flags; - uint32_t len; - /* followed by len bytes (migration input will use this) */ + uint32_t len; /* unused and ignored */ + /* followed by len bytes (unused and ignored) */ char str[0]; };