Fxd PVS-Studio lint warnings
This commit is contained in:
@@ -243,7 +243,8 @@ void netspool_acknowledge(s_netspool_state *state)
|
||||
|
||||
void netspool_end(s_netspool_state *state)
|
||||
{
|
||||
sendstr(state->socket, "END satisfied");
|
||||
int i;
|
||||
i = sendstr(state->socket, "END satisfied");
|
||||
close(state->socket);
|
||||
state->state = NS_NOTINIT;
|
||||
}
|
||||
|
||||
+55
-45
@@ -469,8 +469,10 @@ case 2:
|
||||
|
||||
case 3: // send password on outgoing or pw confirmation on incoming
|
||||
// special empty password is sent if there is no password for the remote addr
|
||||
if (bstate->mode==bmode_incoming_handshake) {
|
||||
if (bstate->password_received) {
|
||||
if (bstate->mode==bmode_incoming_handshake)
|
||||
{
|
||||
if (bstate->password_received)
|
||||
{
|
||||
DEB((D_24554, "send OK, password verified"));
|
||||
buf[0] = BPMSG_OK;
|
||||
*block_type = BINKP_BLK_CMD;
|
||||
@@ -481,45 +483,54 @@ case 3: // send password on outgoing or pw confirmation on incoming
|
||||
DEB((D_24554, "waiting for password from remote"));
|
||||
return 0; // nothing to send
|
||||
}
|
||||
else if (bstate->mode==bmode_outgoing_handshake) {
|
||||
if (!bstate->address_established) {
|
||||
DEB((D_24554, "address not received still"));
|
||||
return 0;
|
||||
}
|
||||
DEB((D_24554, "send password"));
|
||||
else
|
||||
{
|
||||
if (!bstate->address_established)
|
||||
{
|
||||
DEB((D_24554, "address not received still"));
|
||||
return 0;
|
||||
}
|
||||
DEB((D_24554, "send password"));
|
||||
|
||||
buf[0] = BPMSG_PWD;
|
||||
*block_type = BINKP_BLK_CMD;
|
||||
buf[0] = BPMSG_PWD;
|
||||
*block_type = BINKP_BLK_CMD;
|
||||
|
||||
if( bstate->local_data->passwd[0] == '\0' ) {
|
||||
*block_length = 1 + sprintf(buf+1, "-");
|
||||
}
|
||||
else if( bstate->remote_data->options & BINKP_OPT_MD5 ) {
|
||||
char digest_bin[16];
|
||||
char digest_hex[33];
|
||||
|
||||
if(bstate->remote_data->challenge_length==0) {
|
||||
DEB((D_24554, "waiting for challenge"));
|
||||
return 0;
|
||||
if( bstate->local_data->passwd[0] == '\0' )
|
||||
{
|
||||
*block_length = 1 + sprintf(buf+1, "-");
|
||||
}
|
||||
else
|
||||
if( bstate->remote_data->options & BINKP_OPT_MD5 )
|
||||
{
|
||||
char digest_bin[16];
|
||||
char digest_hex[33];
|
||||
|
||||
if(bstate->remote_data->challenge_length==0)
|
||||
{
|
||||
DEB((D_24554, "waiting for challenge"));
|
||||
return 0;
|
||||
}
|
||||
|
||||
md5_cram_get(bstate->local_data->passwd,
|
||||
bstate->remote_data->challenge,
|
||||
bstate->remote_data->challenge_length,
|
||||
digest_bin);
|
||||
|
||||
/* Encode digest to the hex string */
|
||||
string_bin_to_hex(digest_hex, digest_bin, 16);
|
||||
|
||||
*block_length = 1 + sprintf(buf+1,
|
||||
"CRAM-MD5-%s", digest_hex);
|
||||
}
|
||||
else
|
||||
{
|
||||
*block_length = 1 + sprintf(buf+1, "%s", bstate->local_data->passwd);
|
||||
}
|
||||
bstate->phase += 1;
|
||||
return 1;
|
||||
}
|
||||
md5_cram_get(bstate->local_data->passwd, bstate->remote_data->challenge,
|
||||
bstate->remote_data->challenge_length, digest_bin);
|
||||
|
||||
/* Encode digest to the hex string */
|
||||
string_bin_to_hex(digest_hex, digest_bin, 16);
|
||||
|
||||
*block_length = 1 + sprintf(buf+1, "CRAM-MD5-%s", digest_hex);
|
||||
}
|
||||
else {
|
||||
*block_length = 1 + sprintf(buf+1, "%s", bstate->local_data->passwd);
|
||||
}
|
||||
bstate->phase += 1;
|
||||
return 1;
|
||||
}
|
||||
else {
|
||||
log("impossible mode");
|
||||
return -1;
|
||||
}
|
||||
return -1;
|
||||
|
||||
|
||||
|
||||
case 4:
|
||||
@@ -699,12 +710,11 @@ case BPMSG_ADR: /* List of addresses */
|
||||
if (bstate->address_established) {
|
||||
PROTO_ERROR("remote tries to change address");
|
||||
}
|
||||
if( bstate->extracmd[0] != (char)-1 ) return 0; // suspend !!!
|
||||
if( bstate->extracmd[0] != (char)0xFF ) return 0; // suspend !!!
|
||||
binkp_process_ADR(buf+1);
|
||||
|
||||
if( !state.n_remoteaddr ) {
|
||||
log("error: remote did not supplied any addresses");
|
||||
if( bstate->extracmd[0] != (char)-1 ) return 0; // suspend
|
||||
bstate->extracmd[0] = BPMSG_BSY;
|
||||
strcpy(bstate->extracmd+1, "No addresses was presented");
|
||||
bstate->extraislast = true;
|
||||
@@ -783,7 +793,7 @@ case BPMSG_PWD: /* Session password */
|
||||
// lock addresses
|
||||
if( session_addrs_lock(state.remoteaddrs, state.n_remoteaddr) ) {
|
||||
log("error locking addresses of the remote");
|
||||
if( bstate->extracmd[0] != (char)-1 ) return 0; // suspend if extra is occupied
|
||||
if( bstate->extracmd[0] != (char)0xFF ) return 0; // suspend if extra is occupied
|
||||
bstate->extracmd[0] = BPMSG_BSY;
|
||||
strcpy(bstate->extracmd+1, "All addresses are busy");
|
||||
bstate->extraislast = true;
|
||||
@@ -870,7 +880,7 @@ case 2:
|
||||
default:
|
||||
PROTO_ERROR("p_rx_fopen_error");
|
||||
}
|
||||
PROTO_ERROR("never should get here");
|
||||
// PROTO_ERROR("never should get here");
|
||||
|
||||
case BPMSG_OK: /* Password was acknowleged (data ignored) */
|
||||
DEB((D_24554, "received M_OK len=%d", block_length));
|
||||
@@ -879,7 +889,7 @@ case BPMSG_OK: /* Password was acknowleged (data ignored) */
|
||||
}
|
||||
if (session_addrs_lock(state.remoteaddrs, state.n_remoteaddr)) {
|
||||
log("error: unable to lock");
|
||||
if (bstate->extracmd[0]!= (char)-1) return 0;
|
||||
if (bstate->extracmd[0]!= (char)0xFF) return 0;
|
||||
bstate->extracmd[0] = BPMSG_BSY;
|
||||
strcpy(bstate->extracmd+1, "All addresses are busy");
|
||||
bstate->extraislast = true;
|
||||
@@ -989,7 +999,7 @@ case BPMSG_GET: /* Get a file from offset */
|
||||
}
|
||||
DEB((D_24554, "M_GET file %s size %d time %d offset %d", getfi.fn, getfi.sz, getfi.tm, getfi.offs));
|
||||
|
||||
if (bstate->extracmd[0] != (char)-1) return 0;
|
||||
if (bstate->extracmd[0] != (char)0xFF) return 0;
|
||||
|
||||
if (bstate->pi->send) if (p_compfinfo(bstate->pi->send, getfi.fn, getfi.sz, getfi.tm)==0) {
|
||||
DEB((D_24554, "M_GET for currently transmitted file"));
|
||||
@@ -1079,7 +1089,7 @@ case BINKP_BLK_DATA:
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (bstate->extracmd[0] != (char)-1) return 0;
|
||||
if (bstate->extracmd[0] != (char)0xFF) return 0;
|
||||
|
||||
long int n;
|
||||
n = p_rx_writefile(buf, block_length, bstate->pi);
|
||||
|
||||
@@ -43,11 +43,11 @@ const char *Protocols[] =
|
||||
|
||||
static int prot_get_next_file(s_filelist **dest, s_protinfo *pi)
|
||||
{
|
||||
DEB((D_OUTBOUND, "prot_get_next_file")); // %s %d", hint->fn, hint->sz);
|
||||
DEB((D_OUTBOUND, "prot_get_next_file")); // %s %d", hint->fn, hint->sz);
|
||||
s_filelist *ptrl = NULL;
|
||||
s_filelist *best = NULL;
|
||||
s_fsqueue *q = &state.queue;
|
||||
s_filehint *hint = NULL; // M_GET hinting does not work good here as it spec net_name and it is unknown here (especially for PKTs)
|
||||
s_filehint *hint = NULL; // M_GET hinting does not work good here as it spec net_name and it is unknown here (especially for PKTs)
|
||||
|
||||
*dest = NULL;
|
||||
|
||||
@@ -296,10 +296,10 @@ get_next_file:
|
||||
pi->send_left_num -= 1;
|
||||
pi->send_left_size -= ptrl->size;
|
||||
|
||||
if( pi->send_left_size < 0 )
|
||||
pi->send_left_size = 0;
|
||||
//if( pi->send_left_size < 0 )
|
||||
// pi->send_left_size = 0;
|
||||
if( pi->send_left_num < 0 )
|
||||
pi->send_left_num = 0;
|
||||
pi->send_left_num = 0;
|
||||
|
||||
DEB((D_PROT, "p_tx_fopen: now opening \"%s\"", ptrl->fname));
|
||||
|
||||
|
||||
@@ -599,7 +599,7 @@ void emsi_set_sysinfo(s_emsi *emsi, s_emsi *remote_emsi, int hrc,
|
||||
s_cval_entry *hide_ptr;
|
||||
s_faddr *primary = NULL;
|
||||
char xdt[EMSI_MAXXDATETIME+1];
|
||||
time_t xtm;
|
||||
time_t xtm = 0;
|
||||
|
||||
const long options = conf_options(cf_options);
|
||||
const long speed = conf_number(cf_max_speed);
|
||||
|
||||
@@ -554,7 +554,7 @@ int emsi_parsedat(char *emsi_dat, s_emsi *emsi)
|
||||
|
||||
/* password */
|
||||
if( (p=get_field(&emsi_dat, '{', '}')) == NULL ) return(1);
|
||||
if( p && *p ) strnxcpy(emsi->passwd, p, sizeof(emsi->passwd));
|
||||
if( *p ) strnxcpy(emsi->passwd, p, sizeof(emsi->passwd));
|
||||
|
||||
/* link codes */
|
||||
if( (p=get_field(&emsi_dat, '{', '}')) == NULL ) return(1);
|
||||
@@ -669,21 +669,22 @@ int emsi_parsedat(char *emsi_dat, s_emsi *emsi)
|
||||
else if( !strcmp(p, "HFR") ) emsi->compcodes.HFR = 1;
|
||||
}
|
||||
/* Delete last comma from order list */
|
||||
emsi->proto_order[strlen(emsi->proto_order)-1] = '\0';
|
||||
if (strlen(emsi->proto_order) > 0)
|
||||
emsi->proto_order[strlen(emsi->proto_order)-1] = '\0';
|
||||
DEB((D_HSHAKE,"Ordered compcodes: %s",emsi->proto_order));
|
||||
|
||||
/* mailer information */
|
||||
if( (p=get_field(&emsi_dat, '{', '}')) == NULL ) return(1);
|
||||
if( p && *p ) strnxcpy(emsi->m_pid, p, sizeof(emsi->m_pid));
|
||||
if( *p ) strnxcpy(emsi->m_pid, p, sizeof(emsi->m_pid));
|
||||
|
||||
if( (p=get_field(&emsi_dat, '{', '}')) == NULL ) return(1);
|
||||
if( p && *p ) strnxcpy(emsi->m_name, p, sizeof(emsi->m_name));
|
||||
if( *p ) strnxcpy(emsi->m_name, p, sizeof(emsi->m_name));
|
||||
|
||||
if( (p=get_field(&emsi_dat, '{', '}')) == NULL ) return(1);
|
||||
if( p && *p ) strnxcpy(emsi->m_ver, p, sizeof(emsi->m_ver));
|
||||
if( *p ) strnxcpy(emsi->m_ver, p, sizeof(emsi->m_ver));
|
||||
|
||||
if( (p=get_field(&emsi_dat, '{', '}')) == NULL ) return(1);
|
||||
if( p && *p ) strnxcpy(emsi->m_reg, p, sizeof(emsi->m_reg));;
|
||||
if( *p ) strnxcpy(emsi->m_reg, p, sizeof(emsi->m_reg));;
|
||||
}
|
||||
else if( strcmp(tmp, "IDENT") == 0 )
|
||||
{
|
||||
@@ -691,17 +692,17 @@ int emsi_parsedat(char *emsi_dat, s_emsi *emsi)
|
||||
|
||||
if( (tmp=get_field(&emsi_dat, '{', '}')) == NULL ) return(1);
|
||||
if( (p=get_field(&tmp, '[', ']')) == NULL ) return(1);
|
||||
if( p && *p ) strnxcpy(emsi->sname, p, sizeof(emsi->sname));
|
||||
if( *p ) strnxcpy(emsi->sname, p, sizeof(emsi->sname));
|
||||
if( (p=get_field(&tmp, '[', ']')) == NULL ) return(1);
|
||||
if( p && *p ) strnxcpy(emsi->location, p, sizeof(emsi->location));
|
||||
if( *p ) strnxcpy(emsi->location, p, sizeof(emsi->location));
|
||||
if( (p=get_field(&tmp, '[', ']')) == NULL ) return(1);
|
||||
if( p && *p ) strnxcpy(emsi->sysop, p, sizeof(emsi->sysop));
|
||||
if( *p ) strnxcpy(emsi->sysop, p, sizeof(emsi->sysop));
|
||||
if( (p=get_field(&tmp, '[', ']')) == NULL ) return(1);
|
||||
if( p && *p ) strnxcpy(emsi->phone, p, sizeof(emsi->phone));;
|
||||
if( *p ) strnxcpy(emsi->phone, p, sizeof(emsi->phone));;
|
||||
if( (p=get_field(&tmp, '[', ']')) == NULL ) return(1);
|
||||
if( p && *p ) sscanf(p, "%d", &emsi->speed);
|
||||
if( *p ) sscanf(p, "%d", &emsi->speed);
|
||||
if( (p=get_field(&tmp, '[', ']')) == NULL ) return(1);
|
||||
if( p && *p ) strnxcpy(emsi->flags, p, sizeof(emsi->flags));
|
||||
if( *p ) strnxcpy(emsi->flags, p, sizeof(emsi->flags));
|
||||
}
|
||||
else if( strcmp(tmp, "TRX#") == 0 )
|
||||
{
|
||||
@@ -719,7 +720,7 @@ int emsi_parsedat(char *emsi_dat, s_emsi *emsi)
|
||||
else if( strcmp(tmp, "TRAF") == 0 )
|
||||
{
|
||||
if( (p=get_field(&emsi_dat, '{', '}')) == NULL ) return(1);
|
||||
if( p && *p )
|
||||
if( *p )
|
||||
{
|
||||
if( sscanf(p, "%08zX %08zX", &emsi->netmail_size, &emsi->arcmail_size) == 2 )
|
||||
{
|
||||
@@ -735,7 +736,7 @@ int emsi_parsedat(char *emsi_dat, s_emsi *emsi)
|
||||
{
|
||||
if( (p=get_field(&emsi_dat, '{', '}')) == NULL ) return(1);
|
||||
if( (p=get_field(&p, '[', ']')) == NULL ) return(1);
|
||||
if( p && *p )
|
||||
if( *p )
|
||||
{
|
||||
if( sscanf(p, "%08zX", &emsi->files_size) == 1 )
|
||||
{
|
||||
@@ -880,7 +881,7 @@ void emsi_logdat(s_emsi *emsi)
|
||||
if( emsi->compcodes.HFR )
|
||||
strcat(flags, "HFR,");
|
||||
|
||||
if( *flags )
|
||||
if( *flags && (strlen(flags) > 0) )
|
||||
{
|
||||
flags[strlen(flags)-1] = '\0';
|
||||
log(" Options : %s", flags);
|
||||
@@ -921,7 +922,7 @@ void emsi_logdat(s_emsi *emsi)
|
||||
if( emsi->have_emsi )
|
||||
{
|
||||
if( emsi->m_name[0] || emsi->m_pid[0]
|
||||
|| emsi->m_ver[0] || emsi->m_reg )
|
||||
|| emsi->m_ver[0] || emsi->m_reg[0] )
|
||||
{
|
||||
log(" Mailer : %s [%s] %s/%s",
|
||||
emsi->m_name[0] ? string_printable(emsi->m_name) : "?",
|
||||
|
||||
@@ -1549,7 +1549,9 @@ int hydra_batch(s_hydrainfo *hi, s_protinfo *pi)
|
||||
/*
|
||||
* Check current CPS, session time limits, etc.
|
||||
*/
|
||||
if( (rc = p_info(pi, 1)) ) gotoexit(rc);
|
||||
rc = p_info(pi, 1);
|
||||
|
||||
if( rc != PRC_NOERROR ) gotoexit(rc);
|
||||
|
||||
/*
|
||||
* Send/receive as much data as possible, but without delays
|
||||
|
||||
@@ -85,13 +85,12 @@ static void yoohoo_put_hello(char *buffer, s_yoohoo_sysinfo *myhello)
|
||||
* Add domain after the end of 'Node name'
|
||||
* TODO: check it for buffer overflows %-I
|
||||
*/
|
||||
if( state.n_localaddr > 0 && state.localaddrs[0].addr.domain
|
||||
&& *state.localaddrs[0].addr.domain )
|
||||
if( state.n_localaddr > 0 && *state.localaddrs[0].addr.domain )
|
||||
{
|
||||
char *q;
|
||||
if( strlen(myhello->system) + strlen(state.localaddrs[0].addr.domain) > 57 )
|
||||
{
|
||||
if( strlen(state.localaddrs[0].addr.domain) < 60 )
|
||||
if( strlen(state.localaddrs[0].addr.domain) < 60 ) //PVS-Suppress V547
|
||||
q = p + (60 - strlen(state.localaddrs[0].addr.domain));
|
||||
else
|
||||
q = p;
|
||||
|
||||
@@ -210,7 +210,7 @@ int call_system_quiet(const char *connstr, bool inet)
|
||||
if( (exec_cmd = conf_string(cf_run_before_session)) != NULL )
|
||||
{
|
||||
exec_result = system(exec_cmd);
|
||||
if( exec_result = 0 )
|
||||
if( exec_result == 0 )
|
||||
log("external application %s executed with zero return code (%i)", exec_cmd, exec_result);
|
||||
else
|
||||
logerr("external application %s executed with non-zero return code %i", exec_cmd, exec_result);
|
||||
@@ -378,7 +378,7 @@ int call_system_modem(void)
|
||||
|
||||
log("calling with modem %s (%s, %s)",
|
||||
ftn_addrstr(abuf, state.node.addr),
|
||||
(state.node.name && *state.node.name) ? state.node.name : "<none>",
|
||||
( *state.node.name) ? state.node.name : "<none>",
|
||||
string_printable(dialstring));
|
||||
|
||||
/*
|
||||
@@ -526,8 +526,8 @@ default:
|
||||
|
||||
log("calling with internet %s (%s, %s)",
|
||||
ftn_addrstr(abuf, state.node.addr),
|
||||
(state.node.name && *state.node.name ) ? state.node.name : "<none>",
|
||||
(state.node.host && *state.node.host) ? state.node.host : "<none>");
|
||||
(*state.node.name ) ? state.node.name : "<none>",
|
||||
( *state.node.host) ? state.node.host : "<none>");
|
||||
|
||||
memset(abuf, '\0', BF_MAXADDRSTR+1);
|
||||
pbuf = xmalloc(1024);
|
||||
@@ -568,7 +568,7 @@ default:
|
||||
|
||||
|
||||
if( (rc = tcpip_connect(pbuf, state.tcpmode)) == 0
|
||||
&& (rc = tcpip_init() == 0) )
|
||||
&& ( (rc = tcpip_init()) == 0) )
|
||||
{
|
||||
TTYSTATUS(1);
|
||||
rc = session();
|
||||
@@ -862,7 +862,7 @@ int call_system(s_faddr addr, const s_bforce_opts *opts)
|
||||
}
|
||||
if( NULL != state.override.run && strlen(state.override.run) > 0 )
|
||||
{
|
||||
if ( (runrc = system(state.override.run) != 0 ))
|
||||
if ( (runrc = system(state.override.run)) != 0 )
|
||||
{
|
||||
logerr("run script \"%s\" executed with non-zero return value", state.override.run);
|
||||
}
|
||||
@@ -872,7 +872,7 @@ int call_system(s_faddr addr, const s_bforce_opts *opts)
|
||||
// try allowed methods and break if rc == 0
|
||||
rc = -1;
|
||||
|
||||
if( rc && (call_mayuse & CALL_STDIO) )
|
||||
if( call_mayuse & CALL_STDIO )
|
||||
{
|
||||
DEB((D_EVENT,"sess_call: calling stdio"));
|
||||
rc = call_system_quiet(opts->connect, opts->inetd);
|
||||
|
||||
Reference in New Issue
Block a user