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

Commitb01f32c

Browse files
committed
Fix some dubious WAL-parsing code.
Coverity complained about possible buffer overrun in two places added bycommit1eb6d65, and AFAICS it's reasonable to worry: even granting thatthe WAL originator properly truncated the commit GID to GIDSIZE, we shouldnot really bet our lives on that having the same value as it does in thecurrent build. Hence, use strlcpy() not strcpy(), and adjust the pointeradvancement logic to be sure we skip over the whole source string even ifstrlcpy() truncated it.
1 parent05e85d3 commitb01f32c

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

‎src/backend/access/rmgrdesc/xactdesc.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,8 @@ ParseCommitRecord(uint8 info, xl_xact_commit *xlrec, xl_xact_parsed_commit *pars
106106
if (parsed->xinfo&XACT_XINFO_HAS_GID)
107107
{
108108
intgidlen;
109-
strcpy(parsed->twophase_gid,data);
110-
gidlen=strlen(parsed->twophase_gid)+1;
109+
strlcpy(parsed->twophase_gid,data,sizeof(parsed->twophase_gid));
110+
gidlen=strlen(data)+1;
111111
data+=MAXALIGN(gidlen);
112112
}
113113
}
@@ -190,8 +190,8 @@ ParseAbortRecord(uint8 info, xl_xact_abort *xlrec, xl_xact_parsed_abort *parsed)
190190
if (parsed->xinfo&XACT_XINFO_HAS_GID)
191191
{
192192
intgidlen;
193-
strcpy(parsed->twophase_gid,data);
194-
gidlen=strlen(parsed->twophase_gid)+1;
193+
strlcpy(parsed->twophase_gid,data,sizeof(parsed->twophase_gid));
194+
gidlen=strlen(data)+1;
195195
data+=MAXALIGN(gidlen);
196196
}
197197
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp