Skip to content

Commit d6860b1

Browse files
committed
make pythd robust
1 parent f514be5 commit d6860b1

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

pc/request.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ void product::update( T *res )
354354
return;
355355
}
356356
pc_prod_t *prod;
357-
size_t plen = std::max( sizeof(pc_price_t), (size_t)PC_PROD_ACC_SIZE );
357+
size_t plen = std::max( PRICE_ACCOUNT_SIZE, (size_t)PC_PROD_ACC_SIZE );
358358
if ( sizeof( pc_prod_t ) > res->get_data_ref( prod, plen ) ||
359359
prod->magic_ != PC_MAGIC ||
360360
!init_from_account( prod ) ) {
@@ -464,7 +464,7 @@ price::price( const pub_key& acc, product *prod )
464464
preq_->set_account( &apub_ );
465465
areq_->set_sub( this );
466466
preq_->set_sub( this );
467-
size_t tlen = ZSTD_compressBound( sizeof(pc_price_t) );
467+
size_t tlen = ZSTD_compressBound( PRICE_ACCOUNT_SIZE );
468468
pptr_ = (pc_price_t*)new char[tlen];
469469
__builtin_memset( pptr_, 0, tlen );
470470
}
@@ -952,7 +952,7 @@ void price::update( T *res )
952952
}
953953

954954
// get account data
955-
size_t tlen = ZSTD_compressBound( sizeof(pc_price_t) );
955+
size_t tlen = ZSTD_compressBound( PRICE_ACCOUNT_SIZE );
956956
res->get_data_val( pptr_, tlen );
957957
if ( PC_UNLIKELY( pptr_->magic_ != PC_MAGIC ) ) {
958958
on_error_sub( "bad price account header", this );

program/c/src/oracle/oracle.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,8 @@ typedef struct pc_price
190190

191191
static_assert( sizeof( pc_price_t ) == 3312, "" );
192192

193+
const uint64_t PRICE_ACCOUNT_SIZE = TIME_MACHINE_STRUCT_SIZE + sizeof( pc_price_t );
194+
193195
// command enumeration
194196
typedef enum {
195197

0 commit comments

Comments
 (0)