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

Commit82c117c

Browse files
committed
Fix pnstrdup() to not memcpy() the maximum allowed length.
The previous behaviour was dangerous if the length passed wasn't thesize of the underlying buffer, but the maximum size of the underlyingbuffer.Author: Andres FreundDiscussion:https://postgr.es/m/20161003215524.mwz5p45pcverrkyk@alap3.anarazel.de
1 parent8a24179 commit82c117c

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

‎src/backend/utils/mmgr/mcxt.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
#include"postgres.h"
2323

24+
#include"common/string.h"
2425
#include"miscadmin.h"
2526
#include"utils/memdebug.h"
2627
#include"utils/memutils.h"
@@ -1086,10 +1087,14 @@ pstrdup(const char *in)
10861087
char*
10871088
pnstrdup(constchar*in,Sizelen)
10881089
{
1089-
char*out=palloc(len+1);
1090+
char*out;
10901091

1092+
len=pg_strnlen(in,len);
1093+
1094+
out=palloc(len+1);
10911095
memcpy(out,in,len);
10921096
out[len]='\0';
1097+
10931098
returnout;
10941099
}
10951100

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp