Remove SANITIZE_ARRAY
This commit is contained in:
parent
583d7f9586
commit
1cd1e117d0
|
@ -101,7 +101,7 @@ typedef struct OffsetTable
|
||||||
inline bool sanitize (hb_sanitize_context_t *context) {
|
inline bool sanitize (hb_sanitize_context_t *context) {
|
||||||
TRACE_SANITIZE ();
|
TRACE_SANITIZE ();
|
||||||
return SANITIZE_SELF ()
|
return SANITIZE_SELF ()
|
||||||
&& SANITIZE_ARRAY (tableDir, TableDirectory::get_size (), numTables);
|
&& context->check_array (tableDir, TableDirectory::get_size (), numTables);
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -181,24 +181,24 @@ struct hb_sanitize_context_t
|
||||||
this->start = this->end = NULL;
|
this->start = this->end = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool check (const char *base, unsigned int len) const
|
inline bool check (const void *base, unsigned int len) const
|
||||||
{
|
{
|
||||||
bool ret = this->start <= base &&
|
bool ret = this->start <= base &&
|
||||||
base <= this->end &&
|
base <= this->end &&
|
||||||
(unsigned int) (this->end - base) >= len;
|
(unsigned int) (this->end - CharP(base)) >= len;
|
||||||
|
|
||||||
if (HB_DEBUG_SANITIZE && (int) this->debug_depth < (int) HB_DEBUG_SANITIZE) \
|
if (HB_DEBUG_SANITIZE && (int) this->debug_depth < (int) HB_DEBUG_SANITIZE) \
|
||||||
fprintf (stderr, "SANITIZE(%p) %-*d-> check [%p..%p] (%d bytes) in [%p..%p] -> %s\n", \
|
fprintf (stderr, "SANITIZE(%p) %-*d-> check [%p..%p] (%d bytes) in [%p..%p] -> %s\n", \
|
||||||
base,
|
base,
|
||||||
this->debug_depth, this->debug_depth,
|
this->debug_depth, this->debug_depth,
|
||||||
base, base+len, len,
|
base, CharP(base)+len, len,
|
||||||
this->start, this->end,
|
this->start, this->end,
|
||||||
ret ? "pass" : "FAIL");
|
ret ? "pass" : "FAIL");
|
||||||
|
|
||||||
return likely (ret);
|
return likely (ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool check_array (const char *base, unsigned int record_size, unsigned int len) const
|
inline bool check_array (const void *base, unsigned int record_size, unsigned int len) const
|
||||||
{
|
{
|
||||||
bool overflows = len >= ((unsigned int) -1) / record_size;
|
bool overflows = len >= ((unsigned int) -1) / record_size;
|
||||||
|
|
||||||
|
@ -207,7 +207,7 @@ struct hb_sanitize_context_t
|
||||||
fprintf (stderr, "SANITIZE(%p) %-*d-> array [%p..%p] (%d*%d=%ld bytes) in [%p..%p] -> %s\n", \
|
fprintf (stderr, "SANITIZE(%p) %-*d-> array [%p..%p] (%d*%d=%ld bytes) in [%p..%p] -> %s\n", \
|
||||||
base,
|
base,
|
||||||
this->debug_depth, this->debug_depth,
|
this->debug_depth, this->debug_depth,
|
||||||
base, base + (record_size * len), record_size, len, (unsigned long) record_size * len,
|
base, CharP(base) + (record_size * len), record_size, len, (unsigned long) record_size * len,
|
||||||
this->start, this->end,
|
this->start, this->end,
|
||||||
!overflows ? "does not overflow" : "OVERFLOWS FAIL");
|
!overflows ? "does not overflow" : "OVERFLOWS FAIL");
|
||||||
|
|
||||||
|
@ -246,8 +246,6 @@ struct hb_sanitize_context_t
|
||||||
|
|
||||||
#define SANITIZE_MEM(B,L) likely (context->check (CharP(B), (L)))
|
#define SANITIZE_MEM(B,L) likely (context->check (CharP(B), (L)))
|
||||||
|
|
||||||
#define SANITIZE_ARRAY(A,S,L) likely (context->check_array (CharP(A), S, L))
|
|
||||||
|
|
||||||
|
|
||||||
/* Template to sanitize an object. */
|
/* Template to sanitize an object. */
|
||||||
template <typename Type>
|
template <typename Type>
|
||||||
|
@ -556,7 +554,7 @@ struct GenericArrayOf
|
||||||
inline bool sanitize_shallow (hb_sanitize_context_t *context) {
|
inline bool sanitize_shallow (hb_sanitize_context_t *context) {
|
||||||
TRACE_SANITIZE ();
|
TRACE_SANITIZE ();
|
||||||
return SANITIZE_SELF()
|
return SANITIZE_SELF()
|
||||||
&& SANITIZE_ARRAY (this, Type::get_size (), len);
|
&& context->check_array (this, Type::get_size (), len);
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -624,7 +622,7 @@ struct HeadlessArrayOf
|
||||||
|
|
||||||
inline bool sanitize_shallow (hb_sanitize_context_t *context) {
|
inline bool sanitize_shallow (hb_sanitize_context_t *context) {
|
||||||
return SANITIZE_SELF()
|
return SANITIZE_SELF()
|
||||||
&& SANITIZE_ARRAY (this, Type::get_size (), len);
|
&& context->check_array (this, Type::get_size (), len);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool sanitize (hb_sanitize_context_t *context) {
|
inline bool sanitize (hb_sanitize_context_t *context) {
|
||||||
|
|
|
@ -167,7 +167,7 @@ struct ValueFormat : USHORT
|
||||||
TRACE_SANITIZE ();
|
TRACE_SANITIZE ();
|
||||||
unsigned int len = get_len ();
|
unsigned int len = get_len ();
|
||||||
|
|
||||||
if (!SANITIZE_ARRAY (values, get_size (), count)) return false;
|
if (!context->check_array (values, get_size (), count)) return false;
|
||||||
|
|
||||||
if (!has_device ()) return true;
|
if (!has_device ()) return true;
|
||||||
|
|
||||||
|
@ -341,7 +341,7 @@ struct AnchorMatrix
|
||||||
if (!SANITIZE_SELF ()) return false;
|
if (!SANITIZE_SELF ()) return false;
|
||||||
if (unlikely (cols >= ((unsigned int) -1) / rows)) return false;
|
if (unlikely (cols >= ((unsigned int) -1) / rows)) return false;
|
||||||
unsigned int count = rows * cols;
|
unsigned int count = rows * cols;
|
||||||
if (!SANITIZE_ARRAY (matrix, matrix[0].get_size (), count)) return false;
|
if (!context->check_array (matrix, matrix[0].get_size (), count)) return false;
|
||||||
for (unsigned int i = 0; i < count; i++)
|
for (unsigned int i = 0; i < count; i++)
|
||||||
if (!SANITIZE_WITH_BASE (this, matrix[i])) return false;
|
if (!SANITIZE_WITH_BASE (this, matrix[i])) return false;
|
||||||
return true;
|
return true;
|
||||||
|
@ -557,7 +557,7 @@ struct PairSet
|
||||||
TRACE_SANITIZE ();
|
TRACE_SANITIZE ();
|
||||||
if (!SANITIZE_SELF ()) return false;
|
if (!SANITIZE_SELF ()) return false;
|
||||||
unsigned int count = (1 + format_len) * len;
|
unsigned int count = (1 + format_len) * len;
|
||||||
return SANITIZE_ARRAY (array, USHORT::get_size (), count);
|
return context->check_array (array, USHORT::get_size (), count);
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -717,7 +717,7 @@ struct PairPosFormat2
|
||||||
unsigned int stride = len1 + len2;
|
unsigned int stride = len1 + len2;
|
||||||
unsigned int record_size = valueFormat1.get_size () + valueFormat2.get_size ();
|
unsigned int record_size = valueFormat1.get_size () + valueFormat2.get_size ();
|
||||||
unsigned int count = (unsigned int) class1Count * (unsigned int) class2Count;
|
unsigned int count = (unsigned int) class1Count * (unsigned int) class2Count;
|
||||||
return SANITIZE_ARRAY (values, record_size, count) &&
|
return context->check_array (values, record_size, count) &&
|
||||||
valueFormat1.sanitize_values_stride_unsafe (context, CharP(this), &values[0], count, stride) &&
|
valueFormat1.sanitize_values_stride_unsafe (context, CharP(this), &values[0], count, stride) &&
|
||||||
valueFormat2.sanitize_values_stride_unsafe (context, CharP(this), &values[len1], count, stride);
|
valueFormat2.sanitize_values_stride_unsafe (context, CharP(this), &values[len1], count, stride);
|
||||||
}
|
}
|
||||||
|
|
|
@ -445,11 +445,11 @@ struct ContextFormat3
|
||||||
TRACE_SANITIZE ();
|
TRACE_SANITIZE ();
|
||||||
if (!SANITIZE_SELF ()) return false;
|
if (!SANITIZE_SELF ()) return false;
|
||||||
unsigned int count = glyphCount;
|
unsigned int count = glyphCount;
|
||||||
if (!SANITIZE_ARRAY (coverage, OffsetTo<Coverage>::get_size (), count)) return false;
|
if (!context->check_array (coverage, OffsetTo<Coverage>::get_size (), count)) return false;
|
||||||
for (unsigned int i = 0; i < count; i++)
|
for (unsigned int i = 0; i < count; i++)
|
||||||
if (!SANITIZE_WITH_BASE (this, coverage[i])) return false;
|
if (!SANITIZE_WITH_BASE (this, coverage[i])) return false;
|
||||||
LookupRecord *lookupRecord = &StructAtOffset<LookupRecord> (coverage, OffsetTo<Coverage>::get_size () * count);
|
LookupRecord *lookupRecord = &StructAtOffset<LookupRecord> (coverage, OffsetTo<Coverage>::get_size () * count);
|
||||||
return SANITIZE_ARRAY (lookupRecord, LookupRecord::get_size (), lookupCount);
|
return context->check_array (lookupRecord, LookupRecord::get_size (), lookupCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
Loading…
Reference in New Issue