Opened 5 years ago
Closed 5 years ago
#4451 closed defect (fixed)
gserialized_max_header_size is too big
Reported by: | Algunenano | Owned by: | Algunenano |
---|---|---|---|
Priority: | medium | Milestone: | PostGIS 3.0.0 |
Component: | postgis | Version: | master |
Keywords: | Cc: |
Description
The max header size is being calculated as:
return sizeof(GSERIALIZED) + 8 * sizeof(float) + sizeof(int);
But sizeof(GSERIALIZED) takes into account data[1]
, which AFAIK we shouldn't include as it's added after.
A small test case:
#include <stdio.h> #include <stdint.h> typedef struct { uint32_t size; /* For PgSQL use only, use VAR* macros to manipulate. */ uint8_t srid[3]; /* 24 bits of SRID */ uint8_t gflags; /* HasZ, HasM, HasBBox, IsGeodetic */ uint8_t data[1]; /* See gserialized.txt */ } GSERIALIZED; int main() { printf("Size: %d\n", sizeof(GSERIALIZED)); printf("Data: %u\n", (intptr_t)&((GSERIALIZED *)NULL)->data); }
$ ./a.out Size: 12 Data: 8
sizeof(GSERIALIZED) returns 12 bytes, when what we want is 8.
Note:
See TracTickets
for help on using tickets.
PR in https://github.com/postgis/postgis/pull/433