Colorize a chain of references
(chain)
| 455 | |
| 456 | @memoized |
| 457 | def format_reference_chain(chain): |
| 458 | """ |
| 459 | Colorize a chain of references |
| 460 | """ |
| 461 | v = t = vn = None |
| 462 | text = "" |
| 463 | if not chain: |
| 464 | text += "Cannot access memory address" |
| 465 | else: |
| 466 | first = True |
| 467 | for (v, t, vn) in chain: |
| 468 | if t != "value": |
| 469 | text += "%s%s " % ("--> " if not first else "", format_address(v, t)) |
| 470 | else: |
| 471 | text += "%s%s " % ("--> " if not first else "", v) |
| 472 | first = False |
| 473 | |
| 474 | if vn: |
| 475 | text += "(%s)" % vn |
| 476 | else: |
| 477 | if v != "0x0": |
| 478 | s = hex2str(v) |
| 479 | if is_printable(s, "\x00"): |
| 480 | text += "(%s)" % string_repr(s.split(b"\x00")[0]) |
| 481 | return text |
| 482 | |
| 483 | # vulnerable C functions, source: rats/flawfinder |
| 484 | VULN_FUNCTIONS = [ |
no test coverage detected