// The server uses this for verification. int blk_read_verify(struct blk *blk_to_verify) { if(!win) { rconf_init(&rconf); if(!(win=win_alloc(&rconf))) return -1; } gbuf=blk_to_verify->data; gbuf_end=gbuf+blk_to_verify->length; gcp=gbuf; if(!blk && !(blk=blk_alloc())) return -1; blk->length=0; blk->fingerprint=0; // FIX THIS: blk_read should return 1 when it has a block. // But, if the block is too small (because the end of the file // happened), it returns 0, and blks_generate treats it as having found // a final block. // So, here the return of blk_read is ignored and we look at the // position of gcp instead. blk_read(); if(gcp==gbuf_end && blk->fingerprint==blk_to_verify->fingerprint) return 1; return 0; }
int blks_generate_init(void) { rconf_init(&rconf); if(!(win=win_alloc(&rconf)) || !(gbuf=(char *)malloc_w(rconf.blk_max, __func__))) return -1; gbuf_end=gbuf; gcp=gbuf; return 0; }
END_TEST START_TEST(test_win_alloc_error) { struct rconf rconf; struct win *win; alloc_check_init(); rconf_init(&rconf); alloc_errors=1; fail_unless((win=win_alloc(&rconf))==NULL); tear_down(); }