Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit1144ea3

Browse files
committed
Prevent shm_mq_send from reading uninitialized memory.
shm_mq_send_bytes didn't invariably initialize *bytes_written beforereturning, which would cause shm_mq_send to read from uninitializedmemory and add the value it found there to mqh->mqh_partial_bytes.This could cause the next attempt to send a message via the queue tofail an assertion (if the queue was detached) or copy data from agarbage pointer value into the queue (if non-blocking mode was in use).
1 parent250c26b commit1144ea3

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

‎src/backend/storage/ipc/shm_mq.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -676,7 +676,10 @@ shm_mq_send_bytes(shm_mq_handle *mqh, Size nbytes, void *data, bool nowait,
676676

677677
/* Bail out if the queue has been detached. */
678678
if (detached)
679+
{
680+
*bytes_written=sent;
679681
returnSHM_MQ_DETACHED;
682+
}
680683

681684
if (available==0)
682685
{
@@ -691,12 +694,16 @@ shm_mq_send_bytes(shm_mq_handle *mqh, Size nbytes, void *data, bool nowait,
691694
if (nowait)
692695
{
693696
if (shm_mq_get_receiver(mq)==NULL)
697+
{
698+
*bytes_written=sent;
694699
returnSHM_MQ_WOULD_BLOCK;
700+
}
695701
}
696702
elseif (!shm_mq_wait_internal(mq,&mq->mq_receiver,
697703
mqh->mqh_handle))
698704
{
699705
mq->mq_detached= true;
706+
*bytes_written=sent;
700707
returnSHM_MQ_DETACHED;
701708
}
702709
mqh->mqh_counterparty_attached= true;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp