summary |
shortlog |
log |
commit | commitdiff |
review |
tree
raw |
patch |
inline | side by side (from parent 1:
5ec64c5)
This change addresses complaints generated by a recent code scan
Issue-ID: RIC-673
Signed-off-by: E. Scott Daniels <daniels@research.att.com>
Change-Id: I230449eced30477e13ec3eb867a5e16f67d4fae8
13 files changed:
# API and build change and fix summaries. Doc correctsions
# and/or changes are not mentioned here; see the commit messages.
# API and build change and fix summaries. Doc correctsions
# and/or changes are not mentioned here; see the commit messages.
+2020 November 4; Version 4.4.1
+ Changes to correct complaints generated by a code scan. (RIC-673)
+
2020 November 4; Version 4.4.0
Changes to address a potential race condition when route tables
arrive in quick succession. (RIC-674)
2020 November 4; Version 4.4.0
Changes to address a potential race condition when route tables
arrive in quick succession. (RIC-674)
set( major_version "4" ) # should be automatically populated from git tag later, but until CI process sets a tag we use this
set( minor_version "4" )
set( major_version "4" ) # should be automatically populated from git tag later, but until CI process sets a tag we use this
set( minor_version "4" )
set( install_root "${CMAKE_INSTALL_PREFIX}" )
set( install_inc "include/rmr" )
set( install_root "${CMAKE_INSTALL_PREFIX}" )
set( install_inc "include/rmr" )
version 4.0.0, the RMR versions should no longer skip.
version 4.0.0, the RMR versions should no longer skip.
+2020 November 4; Version 4.4.1
+------------------------------
+
+Changes to correct complaints generated by a code scan.
+(Ric-673)
+
+
+
2020 November 4; Version 4.4.0
------------------------------
2020 November 4; Version 4.4.0
------------------------------
vsnprintf( body, sizeof( msg ) - (hlen+2), fmt, argp ); // add in user message formatting it along the way
fprintf( stderr, "%s", msg ); // we grew from printfs so all existing msg have \n; assume there
vsnprintf( body, sizeof( msg ) - (hlen+2), fmt, argp ); // add in user message formatting it along the way
fprintf( stderr, "%s", msg ); // we grew from printfs so all existing msg have \n; assume there
vsnprintf( body, sizeof( msg ) - (hlen+2), fmt, argp ); // add in user message formatting it along the way
fprintf( stderr, "%s", msg ); // we grew from printfs so all existing msg have \n; assume there
vsnprintf( body, sizeof( msg ) - (hlen+2), fmt, argp ); // add in user message formatting it along the way
fprintf( stderr, "%s", msg ); // we grew from printfs so all existing msg have \n; assume there
}
// -------------------- public functions that are needed -----------------
}
// -------------------- public functions that are needed -----------------
}
r->nelements = size; // because we always have an empty element when full
}
r->nelements = size; // because we always have an empty element when full
- if( (r->data = (void **) malloc( sizeof( void** ) * (r->nelements + 1) )) == NULL ) {
+ if( (r->data = (void **) malloc( sizeof( void* ) * (r->nelements + 1) )) == NULL ) {
free( r );
return NULL;
}
free( r );
return NULL;
}
- memset( r->data, 0, sizeof( void** ) * r->nelements );
+ memset( r->data, 0, sizeof( void* ) * r->nelements );
r->pfd = eventfd( 0, EFD_SEMAPHORE | EFD_NONBLOCK ); // in semaphore mode counter is maintained with each insert/extract
return (void *) r;
}
r->pfd = eventfd( 0, EFD_SEMAPHORE | EFD_NONBLOCK ); // in semaphore mode counter is maintained with each insert/extract
return (void *) r;
}
}
parse_meid_ar( ctx->new_rtable, tokens[1], tokens[2], vlevel );
ctx->new_rtable->mupdates++;
}
parse_meid_ar( ctx->new_rtable, tokens[1], tokens[2], vlevel );
ctx->new_rtable->mupdates++;
- if( strcmp( tokens[0], "mme_del" ) == 0 ) {
- if( ntoks < 2 ) {
- rmr_vlog( RMR_VL_ERR, "meid_parse: mme_del record didn't have enough tokens\n" );
- return;
- }
+ if( strcmp( tokens[0], "mme_del" ) == 0 ) { // ntoks < 2 already validated
parse_meid_del( ctx->new_rtable, tokens[1], vlevel );
ctx->new_rtable->mupdates++;
parse_meid_del( ctx->new_rtable, tokens[1], vlevel );
ctx->new_rtable->mupdates++;
if( vfd >= 0 ) {
wbuf[0] = 0;
lseek( vfd, 0, 0 );
if( vfd >= 0 ) {
wbuf[0] = 0;
lseek( vfd, 0, 0 );
- read( vfd, wbuf, 10 );
- vlevel = atoi( wbuf );
+ if( read( vfd, wbuf, 10 ) > 0 ) {
+ vlevel = atoi( wbuf );
+ }
}
read_static_rt( ctx, vlevel ); // seed the route table if one provided
}
read_static_rt( ctx, vlevel ); // seed the route table if one provided
if( vfd >= 0 ) { // if file is open, read current value
rbuf[0] = 0;
lseek( vfd, 0, 0 );
if( vfd >= 0 ) { // if file is open, read current value
rbuf[0] = 0;
lseek( vfd, 0, 0 );
- read( vfd, rbuf, 10 );
- vlevel = atoi( rbuf );
+ if( read( vfd, rbuf, 10 ) > 0 ) {
+ vlevel = atoi( rbuf );
+ }
char const* sp;
int n; // num moved
char const* sp;
int n; // num moved
- if( dest == NULL && src == NULL ) {
+ if( dest == NULL || src == NULL ) {
struct ifaddrs *ele; // pointer into the list
char octs[NI_MAXHOST+1];
char wbuf[NI_MAXHOST+128];
struct ifaddrs *ele; // pointer into the list
char octs[NI_MAXHOST+1];
char wbuf[NI_MAXHOST+128];
+ char* fmt = NULL; // address format (v4 or v6)
char* envp; // at the environment var if there
char* target_if = NULL; // target interface supplied by ENV_BIND_IF
char* tok;
char* envp; // at the environment var if there
char* target_if = NULL; // target interface supplied by ENV_BIND_IF
char* tok;
+ if( *octs && fmt != NULL ) { // possible that we didn't recognise the format (v4 or v6), don't try if we didn't
if( (tok = strchr( octs, '%' )) != NULL ) { // for unknown reasons some ip6 addrs have %if-name appended; truncate
*tok = 0;
}
if( (tok = strchr( octs, '%' )) != NULL ) { // for unknown reasons some ip6 addrs have %if-name appended; truncate
*tok = 0;
}
uta_ctx_t* ctx = NULL;
char bind_info[256]; // bind info
char* proto = "tcp"; // pointer into the proto/port string user supplied
uta_ctx_t* ctx = NULL;
char bind_info[256]; // bind info
char* proto = "tcp"; // pointer into the proto/port string user supplied
+ char* port; // pointer into the proto_port buffer at the port value
char* interface = NULL; // interface to bind to (from RMR_BIND_IF, 0.0.0.0 if not defined)
char* proto_port;
char wbuf[1024]; // work buffer
char* interface = NULL; // interface to bind to (from RMR_BIND_IF, 0.0.0.0 if not defined)
char* proto_port;
char wbuf[1024]; // work buffer
ctx->my_name = (char *) malloc( sizeof( char ) * RMR_MAX_SRC );
if( snprintf( ctx->my_name, RMR_MAX_SRC, "%s:%s", wbuf, port ) >= RMR_MAX_SRC ) { // our registered name is host:port
rmr_vlog( RMR_VL_CRIT, "rmr_init: hostname + port must be less than %d characters; %s:%s is not\n", RMR_MAX_SRC, wbuf, port );
ctx->my_name = (char *) malloc( sizeof( char ) * RMR_MAX_SRC );
if( snprintf( ctx->my_name, RMR_MAX_SRC, "%s:%s", wbuf, port ) >= RMR_MAX_SRC ) { // our registered name is host:port
rmr_vlog( RMR_VL_CRIT, "rmr_init: hostname + port must be less than %d characters; %s:%s is not\n", RMR_MAX_SRC, wbuf, port );
+ free( proto_port ); // some scanners complain that port is not freed; it CANNOT be
}
memset( rrg, 0, sizeof( *rrg ) );
}
memset( rrg, 0, sizeof( *rrg ) );
- if( (rrg->epts = (endpoint_t **) malloc( sizeof( endpoint_t ) * MAX_EP_GROUP )) == NULL ) {
+ if( (rrg->epts = (endpoint_t **) malloc( sizeof( endpoint_t* ) * MAX_EP_GROUP )) == NULL ) {
rmr_vlog( RMR_VL_WARN, "rmr_add_ep: malloc failed for group endpoint array: group=%d\n", group );
free( rrg );
return NULL;
}
rmr_vlog( RMR_VL_WARN, "rmr_add_ep: malloc failed for group endpoint array: group=%d\n", group );
free( rrg );
return NULL;
}
- memset( rrg->epts, 0, sizeof( endpoint_t ) * MAX_EP_GROUP );
+ memset( rrg->epts, 0, sizeof( endpoint_t* ) * MAX_EP_GROUP );
rte->rrgroups[group] = rrg;
rte->rrgroups[group] = rrg;
if( PARANOID_CHECKS ) {
if( ctx == NULL ) {
if( PARANOID_CHECKS ) {
if( ctx == NULL ) {
- if( DEBUG ) rmr_vlog( RMR_VL_DEBUG, "epsock_byname: parinoia check pop ctx=%p\n", ctx, rt );
+ if( DEBUG ) rmr_vlog( RMR_VL_DEBUG, "epsock_byname: parinoia check pop ctx=%p rt=%p\n", ctx, rt );
return FALSE;
}
rt = get_rt( ctx ); // get active rt and bump ref count
return FALSE;
}
rt = get_rt( ctx ); // get active rt and bump ref count
alen = SIgenaddr( abuf, protocol, family, tptr->type, &addr ); // family == 0 for type that suits the address passed in
if( alen <= 0 ) {
alen = SIgenaddr( abuf, protocol, family, tptr->type, &addr ); // family == 0 for type that suits the address passed in
if( alen <= 0 ) {
+ if( addr != NULL ) {
+ free( addr ); // not needed, but scanners complain if we don't overtly do this
+ }
alen = SIgenaddr( abuf, protocol, family, tptr->type, &addr ); // family == 0 for type that suits the address passed in
if( alen <= 0 ) {
alen = SIgenaddr( abuf, protocol, family, tptr->type, &addr ); // family == 0 for type that suits the address passed in
if( alen <= 0 ) {
+ if( addr != NULL ) { // not needed, but scanners complain if we don't overtly do this
+ free( addr );
+ }
extern int SIpoll( struct ginfo_blk *gptr, int msdelay )
{
extern int SIpoll( struct ginfo_blk *gptr, int msdelay )
{
- //extern int deaths; // number of children that died and are zombies
- //extern int sigflags; // flags set by the signal handler routine
-
int fd; // file descriptor for use in this routine
int ((*cbptr)()); // pointer to callback routine to call
int status = SI_OK; // return status
int fd; // file descriptor for use in this routine
int ((*cbptr)()); // pointer to callback routine to call
int status = SI_OK; // return status
if( tpptr->flags & TPF_LISTENFD ) // listen port setup by init?
{ // yes-assume new session req
if( tpptr->flags & TPF_LISTENFD ) // listen port setup by init?
{ // yes-assume new session req
- status = SInewsession( gptr, tpptr ); // make new session
+ SInewsession( gptr, tpptr ); // cannot do anything about failure, so ignore status
}
else // data received on a regular port
if( tpptr->type == SOCK_DGRAM ) // udp socket?
}
else // data received on a regular port
if( tpptr->type == SOCK_DGRAM ) // udp socket?
status = (*cbptr)( gptr->cbtab[SI_CB_RDATA].cbdata, gptr->rbuf, status, buf );
SIcbstat( gptr, status, SI_CB_RDATA ); // handle status
free( buf );
status = (*cbptr)( gptr->cbtab[SI_CB_RDATA].cbdata, gptr->rbuf, status, buf );
SIcbstat( gptr, status, SI_CB_RDATA ); // handle status
free( buf );
+ buf = NULL; // just to be safe
} // end if call back was defined
} // end if status was ok
free( uaddr );
} // end if call back was defined
} // end if status was ok
free( uaddr );
if( gptr->magicnum != MAGICNUM ) { // if not a valid ginfo block
rmr_vlog( RMR_VL_CRIT, "SI95: wait: bad global info struct magic number is wrong\n" );
if( gptr->magicnum != MAGICNUM ) { // if not a valid ginfo block
rmr_vlog( RMR_VL_CRIT, "SI95: wait: bad global info struct magic number is wrong\n" );