Skip to content

Commit 888f5cd

Browse files
committed
Fix skipping over 4B varlena padding bytes
4B varlenas can start with NUL bytes on big endian, so the old coding would eat too many bytes. Instead, handle the 1B cases first and then compute the correct number of padding bytes instead of looking at the byte values. Author: Christoph Berg <[email protected]>
1 parent 38932c5 commit 888f5cd

File tree

1 file changed

+5
-11
lines changed

1 file changed

+5
-11
lines changed

decode.c

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1078,17 +1078,6 @@ extract_data(const char *buffer, unsigned int buff_size, unsigned int *out_size,
10781078
int padding = 0;
10791079
int result = 0;
10801080

1081-
/* Skip padding bytes. */
1082-
while (*buffer == 0x00)
1083-
{
1084-
if (buff_size == 0)
1085-
return -1;
1086-
1087-
buff_size--;
1088-
buffer++;
1089-
padding++;
1090-
}
1091-
10921081
if (VARATT_IS_1B_E(buffer))
10931082
{
10941083
/*
@@ -1153,6 +1142,11 @@ extract_data(const char *buffer, unsigned int buff_size, unsigned int *out_size,
11531142
return result;
11541143
}
11551144

1145+
/* Skip padding bytes. */
1146+
padding = (char *)INTALIGN(buffer) - buffer;
1147+
buffer += padding;
1148+
buff_size -= padding;
1149+
11561150
if (VARATT_IS_4B_U(buffer) && buff_size >= 4)
11571151
{
11581152
/*

0 commit comments

Comments
 (0)