const char *unpacker_get_string(UNPACKER *p) { char *ptr; if(p->error || p->current >= p->end) return ""; ptr = (char *)p->current; while(*p->current) /* skip the string */ { p->current++; if(p->current == p->end) { packing_error(p); return ""; } } p->current++; /* sanitize all strings */ //str_sanitize(ptr); if (config.zpack2_compatible_cyrillic) zpack2_convert_cyrillic(ptr, true); return ptr; }
void packer_add_string(PACKER *p, const char *str, int limit) { if(p->error) return; if(stress_prob(0.1f)) { str = stress_get_string(0); limit = 0; } char * ptr = (char *)p->current; /* */ if(limit > 0) { while(*str && limit != 0) { *p->current++ = *str++; limit--; if(p->current >= p->end) { packing_error(p); break; } } *p->current++ = 0; } else { while(*str) { *p->current++ = *str++; if(p->current >= p->end) { packing_error(p); break; } } *p->current++ = 0; } if (config.zpack2_compatible_cyrillic) zpack2_convert_cyrillic(ptr, false); }
int unpacker_get_int(UNPACKER *p) { int i; if(p->error) return 0; if(p->current >= p->end) { packing_error(p); return 0; } p->current = vint_unpack(p->current, &i); if(p->current > p->end) { packing_error(p); return 0; } return i; }
void packer_add_string(PACKER *p, const char *str, int limit) { if(p->error) return; /* */ if(limit > 0) { while(*str && limit != 0) { *p->current++ = *str++; limit--; if(p->current >= p->end) { packing_error(p); break; } } *p->current++ = 0; } else { while(*str) { *p->current++ = *str++; if(p->current >= p->end) { packing_error(p); break; } } *p->current++ = 0; } }
void packer_add_raw(PACKER *p, const unsigned char *data, int size) { if(p->error) return; if(p->current+size >= p->end) { packing_error(p); return; } while(size) { *p->current++ = *data++; size--; } }
const unsigned char *unpacker_get_raw(UNPACKER *p, int size) { const unsigned char *ptr = p->current; if(p->error) return 0; /* check for nasty sizes */ if(size < 0 || p->current+size > p->end) { packing_error(p); return 0; } /* "unpack" the data */ p->current += size; return ptr; }
const char *unpacker_get_string(UNPACKER *p) { char *ptr; if(p->error || p->current >= p->end) return ""; ptr = (char *)p->current; while(*p->current) /* skip the string */ { p->current++; if(p->current == p->end) { packing_error(p); return ""; } } p->current++; /* sanitize all strings */ str_sanitize(ptr); return ptr; }