Skip to content

Commit 7b78af4

Browse files
Fix bad free of cms data (DoS only)
handle_unlock_token() set the CMS data to an offset of an allocated buffer, rather than something allocated in its own right. cms_set_pw_data() would then attempt to free this value. Additionally, should pesignd not take SIGABRT at that point, handle_unlock_token() would then also free buffer. Signed-off-by: Robbie Harwood <[email protected]>
1 parent f783f05 commit 7b78af4

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/daemon.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ handle_unlock_token(context *ctx, struct pollfd *pollfd, socklen_t size)
153153
struct msghdr msg;
154154
struct iovec iov;
155155
ssize_t n;
156+
char *pin = NULL;
156157

157158
int rc = cms_context_alloc(&ctx->cms);
158159
if (rc < 0) {
@@ -220,7 +221,8 @@ handle_unlock_token(context *ctx, struct pollfd *pollfd, socklen_t size)
220221
if (!ctx->cms->tokenname)
221222
goto oom;
222223

223-
char *pin = (char *)tp->value;
224+
if (!tp->value)
225+
pin = strndup((char *)tp->value, tp->size);
224226
if (!pin)
225227
goto oom;
226228

0 commit comments

Comments
 (0)