~ubuntu-branches/ubuntu/utopic/tlsdate/utopic-proposed

« back to all changes in this revision

Viewing changes to src/proxy-bio-unittest.c

  • Committer: Package Import Robot
  • Author(s): Jacob Appelbaum
  • Date: 2013-01-22 23:08:21 UTC
  • mfrom: (1.1.1)
  • Revision ID: package-import@ubuntu.com-20130122230821-820ay2kh785on6yc
Tags: 0.0.5-1
New upstream version.

Show diffs side-by-side

added added

removed removed

Lines of Context:
7
7
 
8
8
#include <alloca.h>
9
9
 
10
 
#include "proxy-bio.h"
11
 
#include "test-bio.h"
12
 
#include "test_harness.h"
13
 
#include "tlsdate.h"
 
10
#include "src/proxy-bio.h"
 
11
#include "src/test-bio.h"
 
12
#include "src/test_harness.h"
 
13
#include "src/tlsdate.h"
14
14
 
15
15
FIXTURE(test_bio) {
16
16
  BIO *test;
37
37
 
38
38
int need_out_bytes(BIO *test, const unsigned char *out, size_t sz)
39
39
{
40
 
  unsigned char *buf = alloca(sz);
 
40
  unsigned char *buf = malloc(sz);
41
41
  size_t i;
 
42
  int result;
42
43
  if (!buf)
43
44
    return 1;
44
45
  if (BIO_test_output_left(test) <  sz) {
45
46
    fprintf(TH_LOG_STREAM, "not enough output: %d < %d\n",
46
47
            (int)BIO_test_output_left(test), (int)sz);
 
48
    free(buf);
47
49
    return 2;
48
50
  }
49
 
  if (BIO_test_get_output(test, buf, sz) != sz)
 
51
  if (BIO_test_get_output(test, buf, sz) != sz) {
 
52
    free(buf);
50
53
    return 3;
 
54
  }
51
55
  if (memcmp(buf, out, sz)) {
52
56
    for (i = 0; i < sz; i++) {
53
57
      if (buf[i] != out[i])
56
60
                buf[i], out[i]);
57
61
    }
58
62
  }
59
 
  return memcmp(buf, out, sz);
 
63
  result = memcmp(buf, out, sz);
 
64
  free(buf);
 
65
  return result;
60
66
}
61
67
 
62
68
int need_out_byte(BIO *test, unsigned char out)