Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if not_terminated.symbolic:
not_already_terminated = bl.Symbol(unique_name('tmp'))
s.solver.add(not_already_terminated == not_terminated)
else:
not_already_terminated = not_terminated
count += 1
bytes.reverse()
result = None
prev_result = None
for (not_already_terminated, byte1, byte2) in bytes:
if result is None:
result = bv.if_then_else(
byte1 == byte2,
zero,
bv.if_then_else(
byte1 < byte2,
first_smaller,
first_larger))
else:
result = bv.if_then_else(
not_already_terminated,
bv.if_then_else(
byte1 == byte2,
prev_result,
bv.if_then_else(
byte1 < byte2,
first_smaller,
first_larger)),
def op_bisz(i, s):
a = operand_value(s, i.input0)
dst = i.output
result = bv.if_then_else(
a == bv.Constant(a.size, 0),
bv.Constant(dst.size, 1),
bv.Constant(dst.size, 0))
s.registers[dst.name] = result
return [s]
characters.append((not_already_terminated, char1, char2))
not_already_terminated = not_terminated
if ((not char1.symbolic and char1.value == 0)
or (not char2.symbolic and char2.value == 0)):
break
characters.reverse()
result = None
prev_result = None
for (not_already_terminated, char1, char2) in characters:
if result is None:
result = bv.if_then_else(
char1 == char2,
zero,
bv.if_then_else(
char1 < char2,
first_smaller,
first_larger))
else:
result = bv.if_then_else(
not_already_terminated,
bv.if_then_else(
char1 == char2,
prev_result,
bv.if_then_else(
char1 < char2,
first_smaller,
first_larger)),
bytes.reverse()
result = None
prev_result = None
for (not_already_terminated, byte1, byte2) in bytes:
if result is None:
result = bv.if_then_else(
byte1 == byte2,
zero,
bv.if_then_else(
byte1 < byte2,
first_smaller,
first_larger))
else:
result = bv.if_then_else(
not_already_terminated,
bv.if_then_else(
byte1 == byte2,
prev_result,
bv.if_then_else(
byte1 < byte2,
first_smaller,
first_larger)),
prev_result)
# this reduces the memory footprint_ of the resulting expression
# significantly
prev_result = bv.Symbol(ptr1.size, unique_name('tmp'))
s.solver.add(prev_result == result)
if result.symbolic:
result = None
prev_result = None
for (not_already_terminated, byte1, byte2) in bytes:
if result is None:
result = bv.if_then_else(
byte1 == byte2,
zero,
bv.if_then_else(
byte1 < byte2,
first_smaller,
first_larger))
else:
result = bv.if_then_else(
not_already_terminated,
bv.if_then_else(
byte1 == byte2,
prev_result,
bv.if_then_else(
byte1 < byte2,
first_smaller,
first_larger)),
prev_result)
# this reduces the memory footprint_ of the resulting expression
# significantly
prev_result = bv.Symbol(ptr1.size, unique_name('tmp'))
s.solver.add(prev_result == result)
if result.symbolic:
result_symbol = bv.Symbol(result.size, unique_name('memcmp'))
s.solver.add(result_symbol == result)
if not_terminated.symbolic:
not_already_terminated = bl.Symbol(unique_name('tmp'))
s_.solver.add(not_already_terminated == not_terminated)
else:
not_already_terminated = not_terminated
count += 1
bytes.reverse()
result = None
prev_result = None
for (not_already_terminated, byte, count) in bytes:
if result is None:
result = bv.if_then_else(
byte == value,
ptr + bv.Constant(ptr.size, count),
null)
else:
result = bv.if_then_else(
not_already_terminated,
bv.if_then_else(
byte == value,
ptr + bv.Constant(ptr.size, count),
prev_result),
prev_result)
# this reduces the memory footprint_ of the resulting expression
# significantly
prev_result = bv.Symbol(ptr.size, unique_name('tmp'))
s_.solver.add(prev_result == result)
def op_equ(i, s):
a = operand_value(s, i.input0)
b = operand_value(s, i.input1)
dst = i.output
result = bv.if_then_else(
a == b,
bv.Constant(dst.size, 1),
bv.Constant(dst.size, 0))
s.registers[dst.name] = result
return [s]
characters.reverse()
result = None
prev_result = None
for (not_already_terminated, char1, char2) in characters:
if result is None:
result = bv.if_then_else(
char1 == char2,
zero,
bv.if_then_else(
char1 < char2,
first_smaller,
first_larger))
else:
result = bv.if_then_else(
not_already_terminated,
bv.if_then_else(
char1 == char2,
prev_result,
bv.if_then_else(
char1 < char2,
first_smaller,
first_larger)),
prev_result)
# this reduces the memory footprint_ of the resulting expression
# significantly
prev_result = bv.Symbol(32, unique_name('tmp'))
s.solver.add(prev_result == result)
if result.symbolic:
not_already_terminated = not_terminated
if ((not char1.symbolic and char1.value == 0)
or (not char2.symbolic and char2.value == 0)):
break
characters.reverse()
result = None
prev_result = None
for (not_already_terminated, char1, char2) in characters:
if result is None:
result = bv.if_then_else(
char1 == char2,
zero,
bv.if_then_else(
char1 < char2,
first_smaller,
first_larger))
else:
result = bv.if_then_else(
not_already_terminated,
bv.if_then_else(
char1 == char2,
prev_result,
bv.if_then_else(
char1 < char2,
first_smaller,
first_larger)),
prev_result)
# this reduces the memory footprint_ of the resulting expression