Commit ddc1ab05 authored by Zack Weinberg's avatar Zack Weinberg
Browse files

Add 'pgen_fake' payload generator, use it if traces aren't available.

 * src/pgen_fake.cc: New file.
 * Makefile.am: Build it.  Integrate it with 'make check'.

 * src/compression.cc: Distinguish an inflate failure due to inadequate
   output buffer space from other causes.
 * src/steg/swfSteg.cc: Enlarge the inflate output buffer as necessary.

 * src/pgen.h: Make internal padding in pentry_header explicit.
 * src/steg/payloads.cc: Remove overly chatty log_debug messages which
   were causing test_tl to deadlock.
parent 949aa954
Loading
Loading
Loading
Loading
+18 −1
Original line number Diff line number Diff line
@@ -62,6 +62,15 @@ stegotorus_DEPENDENCIES = libstegotorus.a stamp-audit-globals

## payload trace generators

bin_PROGRAMS += pgen_fake
pgen_fake_SOURCES = \
	src/pgen_fake.cc \
	src/util.cc \
	src/rng.cc \
	src/base64.cc

pgen_fake_LDADD = $(libcrypto_LIBS)

# pgen_pcap is only built if we have libpcap
if HAVE_PCAP
bin_PROGRAMS += pgen_pcap
@@ -171,7 +180,15 @@ check-local:
	$(AM_V_at) ./unittests
if INTEGRATION_TESTS
	@echo --- Integration tests ---
	[ -e traces ] || ln -s $(srcdir)/traces .
	@set -ex; if [ ! -e traces ]; then \
	  if [ -e $(srcdir)/../steg-traces ]; then \
	    ln -s $(srcdir)/../steg-traces traces; \
	  elif [ -e $(srcdir)/traces ]; then \
	    ln -s $(srcdir)/traces traces; \
	  else \
	    mkdir traces && ./pgen_fake; \
	  fi; \
	fi
	$(AM_V_at) $(PYTHON) -m unittest discover -s $(srcdir)/src/test -p 'test_*.py' -v
else
	@echo !!! Integration tests skipped !!!
+4 −0
Original line number Diff line number Diff line
@@ -91,6 +91,10 @@ decompress(const uint8_t *source, size_t slen, uint8_t *dest, size_t dlen)
  strm.avail_out = dlen;

  ret = inflate(&strm, Z_FINISH);
  if (ret == Z_BUF_ERROR) {
    inflateEnd(&strm);
    return -2; // need more space
  }
  if (ret != Z_STREAM_END) {
    log_warn("decompression failure: %s", strm.msg);
    inflateEnd(&strm);
+2 −0
Original line number Diff line number Diff line
@@ -14,8 +14,10 @@
/* struct for reading in the payload_gen dump file */
struct pentry_header {
  uint16_t ptype;
  uint8_t  pad1[2];
  uint32_t length;
  uint16_t port; /* network format */
  uint8_t  pad2[2];
};

#endif

src/pgen_fake.cc

0 → 100644
+662 −0

File added.

Preview size limit exceeded, changes collapsed.

+0 −2
Original line number Diff line number Diff line
@@ -1297,9 +1297,7 @@ init_PDF_payload_pool(payloads& pl, int len, int type, int minCapacity)
      // can encode in the pdf doc 
      // cap = minCapacity+1;
      cap = capacityPDF(msgbuf, p->length);
      log_debug("got pdf (index %d) with capacity %d", r, cap);
      if (cap > minCapacity) {
	log_debug("pdf (index %d) greater than mincapacity %d", cnt, minCapacity);
	pl.typePayloadCap[contentType][cnt] = (cap-PDF_DELIMITER_SIZE)/2;
	pl.typePayload[contentType][cnt] = r;
	cnt++;
Loading