PostGIS  2.4.9dev-r@@SVN_REVISION@@

◆ lwgeom_from_wkb()

LWGEOM* lwgeom_from_wkb ( const uint8_t wkb,
const size_t  wkb_size,
const char  check 
)

WKB inputs must have a declared size, to prevent malformed WKB from reading off the end of the memory segment (this stops a malevolent user from declaring a one-ring polygon to have 10 rings, causing the WKB reader to walk off the end of the memory).

Check is a bitmask of: LW_PARSER_CHECK_MINPOINTS, LW_PARSER_CHECK_ODD, LW_PARSER_CHECK_CLOSURE, LW_PARSER_CHECK_NONE, LW_PARSER_CHECK_ALL

Definition at line 772 of file lwin_wkb.c.

References wkb_parse_state::check, wkb_parse_state::has_m, wkb_parse_state::has_srid, wkb_parse_state::has_z, LW_FALSE, LW_PARSER_CHECK_NONE, lwgeom_from_wkb_state(), wkb_parse_state::lwtype, wkb_parse_state::pos, s, wkb_parse_state::srid, SRID_UNKNOWN, wkb_parse_state::swap_bytes, wkb_parse_state::wkb, and wkb_parse_state::wkb_size.

Referenced by cu_wkb_in(), geography_from_binary(), geography_recv(), lwgeom_from_hexwkb(), LWGEOM_from_WKB(), LWGEOM_in(), LWGEOM_recv(), LWGEOMFromEWKB(), rt_raster_gdal_polygonize(), rt_raster_gdal_rasterize(), and test_wkb_leak().

773 {
775 
776  /* Initialize the state appropriately */
777  s.wkb = wkb;
778  s.wkb_size = wkb_size;
779  s.swap_bytes = LW_FALSE;
780  s.check = check;
781  s.lwtype = 0;
782  s.srid = SRID_UNKNOWN;
783  s.has_z = LW_FALSE;
784  s.has_m = LW_FALSE;
785  s.has_srid = LW_FALSE;
786  s.pos = wkb;
787 
788  /* Hand the check catch-all values */
789  if ( check & LW_PARSER_CHECK_NONE )
790  s.check = 0;
791  else
792  s.check = check;
793 
794  return lwgeom_from_wkb_state(&s);
795 }
uint32_t lwtype
Definition: lwin_wkb.c:41
const uint8_t * wkb
Definition: lwin_wkb.c:37
#define LW_PARSER_CHECK_NONE
Definition: liblwgeom.h:2013
size_t wkb_size
Definition: lwin_wkb.c:38
#define LW_FALSE
Definition: liblwgeom.h:77
#define SRID_UNKNOWN
Unknown SRID value.
Definition: liblwgeom.h:188
char * s
Definition: cu_in_wkt.c:23
LWGEOM * lwgeom_from_wkb_state(wkb_parse_state *s)
Internal function declarations.
Definition: lwin_wkb.c:676
uint32_t srid
Definition: lwin_wkb.c:42
Used for passing the parse state between the parsing functions.
Definition: lwin_wkb.c:35
const uint8_t * pos
Definition: lwin_wkb.c:46
Here is the call graph for this function:
Here is the caller graph for this function: