PostGIS  2.5.1dev-r@@SVN_REVISION@@

◆ lwgeom_from_twkb()

LWGEOM* lwgeom_from_twkb ( const uint8_t twkb,
size_t  twkb_size,
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 656 of file lwin_twkb.c.

References twkb_parse_state::check, twkb_parse_state::coords, LWDEBUG, LWDEBUGF, lwgeom_from_twkb_state(), twkb_parse_state::pos, s, twkb_parse_state::twkb, twkb_parse_state::twkb_end, and TWKB_IN_MAXCOORDS.

Referenced by cu_twkb_idlist(), cu_twkb_in(), and LWGEOMFromTWKB().

657 {
658  int64_t coords[TWKB_IN_MAXCOORDS] = {0, 0, 0, 0};
660 
661  LWDEBUG(2,"Entering lwgeom_from_twkb");
662  LWDEBUGF(4,"twkb_size: %d",(int) twkb_size);
663 
664  /* Zero out the state */
665  memset(&s, 0, sizeof(twkb_parse_state));
666 
667  /* Initialize the state appropriately */
668  s.twkb = s.pos = twkb;
669  s.twkb_end = twkb + twkb_size;
670  s.check = check;
671  s.coords = coords;
672 
673  /* Read the rest of the geometry */
674  return lwgeom_from_twkb_state(&s);
675 }
const uint8_t * twkb_end
Definition: lwin_twkb.c:40
uint32_t check
Definition: lwin_twkb.c:43
#define LWDEBUG(level, msg)
Definition: lwgeom_log.h:83
const uint8_t * twkb
Definition: lwin_twkb.c:39
#define TWKB_IN_MAXCOORDS
Definition: lwin_twkb.c:31
int64_t * coords
Definition: lwin_twkb.c:65
char * s
Definition: cu_in_wkt.c:23
Used for passing the parse state between the parsing functions.
Definition: lwin_twkb.c:36
const uint8_t * pos
Definition: lwin_twkb.c:41
LWGEOM * lwgeom_from_twkb_state(twkb_parse_state *s)
Internal function declarations.
Definition: lwin_twkb.c:562
#define LWDEBUGF(level, msg,...)
Definition: lwgeom_log.h:88
Here is the call graph for this function:
Here is the caller graph for this function: