mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-05-25 15:53:56 +00:00
Merge pull request #14454 from opensourcerouting/coverity-20230920
lib: fix a bunch of coverity nits
This commit is contained in:
commit
cd3bd19314
@ -1089,7 +1089,9 @@ static void elffile_add_dynreloc(struct elffile *w, Elf_Data *reldata,
|
|||||||
symidx = relw->symidx = GELF_R_SYM(rela->r_info);
|
symidx = relw->symidx = GELF_R_SYM(rela->r_info);
|
||||||
sym = relw->sym = gelf_getsym(symdata, symidx, &relw->_sym);
|
sym = relw->sym = gelf_getsym(symdata, symidx, &relw->_sym);
|
||||||
if (sym) {
|
if (sym) {
|
||||||
relw->symname = elfdata_strptr(strdata, sym->st_name);
|
if (strdata)
|
||||||
|
relw->symname = elfdata_strptr(strdata,
|
||||||
|
sym->st_name);
|
||||||
relw->symvalid = GELF_ST_TYPE(sym->st_info)
|
relw->symvalid = GELF_ST_TYPE(sym->st_info)
|
||||||
!= STT_NOTYPE;
|
!= STT_NOTYPE;
|
||||||
relw->unresolved = sym->st_shndx == SHN_UNDEF;
|
relw->unresolved = sym->st_shndx == SHN_UNDEF;
|
||||||
|
@ -791,7 +791,12 @@ static struct event *thread_get(struct event_loop *m, uint8_t type,
|
|||||||
thread->master = m;
|
thread->master = m;
|
||||||
thread->arg = arg;
|
thread->arg = arg;
|
||||||
thread->yield = EVENT_YIELD_TIME_SLOT; /* default */
|
thread->yield = EVENT_YIELD_TIME_SLOT; /* default */
|
||||||
thread->ref = NULL;
|
/* thread->ref is zeroed either by XCALLOC above or by memset before
|
||||||
|
* being put on the "unuse" list by thread_add_unuse().
|
||||||
|
* Setting it here again makes coverity complain about a missing
|
||||||
|
* lock :(
|
||||||
|
*/
|
||||||
|
/* thread->ref = NULL; */
|
||||||
thread->ignore_timer_late = false;
|
thread->ignore_timer_late = false;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -28,6 +28,7 @@ struct ipaddr {
|
|||||||
enum ipaddr_type_t ipa_type;
|
enum ipaddr_type_t ipa_type;
|
||||||
union {
|
union {
|
||||||
uint8_t addr;
|
uint8_t addr;
|
||||||
|
uint8_t addrbytes[16];
|
||||||
struct in_addr _v4_addr;
|
struct in_addr _v4_addr;
|
||||||
struct in6_addr _v6_addr;
|
struct in6_addr _v6_addr;
|
||||||
} ip;
|
} ip;
|
||||||
|
@ -2691,7 +2691,6 @@ void nb_init(struct event_loop *tm,
|
|||||||
size_t nmodules, bool db_enabled)
|
size_t nmodules, bool db_enabled)
|
||||||
{
|
{
|
||||||
struct yang_module *loaded[nmodules], **loadedp = loaded;
|
struct yang_module *loaded[nmodules], **loadedp = loaded;
|
||||||
bool explicit_compile;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Currently using this explicit compile feature in libyang2 leads to
|
* Currently using this explicit compile feature in libyang2 leads to
|
||||||
@ -2699,8 +2698,9 @@ void nb_init(struct event_loop *tm,
|
|||||||
* of modules until they have all been loaded into the context. This
|
* of modules until they have all been loaded into the context. This
|
||||||
* avoids multiple recompiles of the same modules as they are
|
* avoids multiple recompiles of the same modules as they are
|
||||||
* imported/augmented etc.
|
* imported/augmented etc.
|
||||||
|
* (Done as a #define to make coverity happy)
|
||||||
*/
|
*/
|
||||||
explicit_compile = false;
|
#define explicit_compile false
|
||||||
|
|
||||||
nb_db_enabled = db_enabled;
|
nb_db_enabled = db_enabled;
|
||||||
|
|
||||||
|
@ -261,7 +261,7 @@ int evpn_type5_prefix_match(const struct prefix *n, const struct prefix *p)
|
|||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
prefixlen = evp->prefix.prefix_addr.ip_prefix_length;
|
prefixlen = evp->prefix.prefix_addr.ip_prefix_length;
|
||||||
np = &evp->prefix.prefix_addr.ip.ip.addr;
|
np = evp->prefix.prefix_addr.ip.ip.addrbytes;
|
||||||
|
|
||||||
/* If n's prefix is longer than p's one return 0. */
|
/* If n's prefix is longer than p's one return 0. */
|
||||||
if (prefixlen > p->prefixlen)
|
if (prefixlen > p->prefixlen)
|
||||||
|
@ -68,7 +68,7 @@ io_print(struct io_state *iop, const CHAR * __restrict ptr, size_t len)
|
|||||||
{
|
{
|
||||||
size_t copylen = len;
|
size_t copylen = len;
|
||||||
|
|
||||||
if (!iop->cb)
|
if (!iop->cb || !len)
|
||||||
return 0;
|
return 0;
|
||||||
if (iop->avail < copylen)
|
if (iop->avail < copylen)
|
||||||
copylen = iop->avail;
|
copylen = iop->avail;
|
||||||
|
@ -344,7 +344,7 @@ void HMAC__SHA256_Final(unsigned char digest[32], HMAC_SHA256_CTX *ctx)
|
|||||||
void PBKDF2_SHA256(const uint8_t *passwd, size_t passwdlen, const uint8_t *salt,
|
void PBKDF2_SHA256(const uint8_t *passwd, size_t passwdlen, const uint8_t *salt,
|
||||||
size_t saltlen, uint64_t c, uint8_t *buf, size_t dkLen)
|
size_t saltlen, uint64_t c, uint8_t *buf, size_t dkLen)
|
||||||
{
|
{
|
||||||
HMAC_SHA256_CTX PShctx, hctx;
|
HMAC_SHA256_CTX PShctx = {}, hctx;
|
||||||
size_t i;
|
size_t i;
|
||||||
uint8_t ivec[4];
|
uint8_t ivec[4];
|
||||||
uint8_t U[32];
|
uint8_t U[32];
|
||||||
|
@ -2368,8 +2368,7 @@ static void vtysh_read(struct event *thread)
|
|||||||
printf("result: %d\n", ret);
|
printf("result: %d\n", ret);
|
||||||
printf("vtysh node: %d\n", vty->node);
|
printf("vtysh node: %d\n", vty->node);
|
||||||
#endif /* VTYSH_DEBUG */
|
#endif /* VTYSH_DEBUG */
|
||||||
|
if (vty->pass_fd >= 0) {
|
||||||
if (vty->pass_fd != -1) {
|
|
||||||
memset(vty->pass_fd_status, 0, 4);
|
memset(vty->pass_fd_status, 0, 4);
|
||||||
vty->pass_fd_status[3] = ret;
|
vty->pass_fd_status[3] = ret;
|
||||||
vty->status = VTY_PASSFD;
|
vty->status = VTY_PASSFD;
|
||||||
@ -2387,7 +2386,9 @@ static void vtysh_read(struct event *thread)
|
|||||||
* => skip vty_event(VTYSH_READ, vty)!
|
* => skip vty_event(VTYSH_READ, vty)!
|
||||||
*/
|
*/
|
||||||
return;
|
return;
|
||||||
}
|
} else
|
||||||
|
/* normalize other invalid values */
|
||||||
|
vty->pass_fd = -1;
|
||||||
|
|
||||||
/* hack for asynchronous "write integrated"
|
/* hack for asynchronous "write integrated"
|
||||||
* - other commands in "buf" will be ditched
|
* - other commands in "buf" will be ditched
|
||||||
|
@ -877,10 +877,15 @@ static int zlog_5424_open(struct zlog_cfg_5424 *zcf, int sock_type)
|
|||||||
|
|
||||||
switch (zcf->dst) {
|
switch (zcf->dst) {
|
||||||
case ZLOG_5424_DST_NONE:
|
case ZLOG_5424_DST_NONE:
|
||||||
break;
|
return -1;
|
||||||
|
|
||||||
case ZLOG_5424_DST_FD:
|
case ZLOG_5424_DST_FD:
|
||||||
fd = dup(zcf->fd);
|
fd = dup(zcf->fd);
|
||||||
|
if (fd < 0) {
|
||||||
|
flog_err_sys(EC_LIB_SYSTEM_CALL,
|
||||||
|
"failed to dup() log file descriptor: %m (FD limit too low?)");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
optlen = sizeof(sock_type);
|
optlen = sizeof(sock_type);
|
||||||
if (!getsockopt(fd, SOL_SOCKET, SO_TYPE, &sock_type, &optlen)) {
|
if (!getsockopt(fd, SOL_SOCKET, SO_TYPE, &sock_type, &optlen)) {
|
||||||
@ -891,7 +896,7 @@ static int zlog_5424_open(struct zlog_cfg_5424 *zcf, int sock_type)
|
|||||||
|
|
||||||
case ZLOG_5424_DST_FIFO:
|
case ZLOG_5424_DST_FIFO:
|
||||||
if (!zcf->filename)
|
if (!zcf->filename)
|
||||||
break;
|
return -1;
|
||||||
|
|
||||||
if (!zcf->file_nocreate) {
|
if (!zcf->file_nocreate) {
|
||||||
frr_with_privs (lib_privs) {
|
frr_with_privs (lib_privs) {
|
||||||
@ -904,7 +909,7 @@ static int zlog_5424_open(struct zlog_cfg_5424 *zcf, int sock_type)
|
|||||||
if (err == 0)
|
if (err == 0)
|
||||||
do_chown = true;
|
do_chown = true;
|
||||||
else if (errno != EEXIST)
|
else if (errno != EEXIST)
|
||||||
break;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
flags = O_NONBLOCK;
|
flags = O_NONBLOCK;
|
||||||
@ -912,7 +917,7 @@ static int zlog_5424_open(struct zlog_cfg_5424 *zcf, int sock_type)
|
|||||||
|
|
||||||
case ZLOG_5424_DST_FILE:
|
case ZLOG_5424_DST_FILE:
|
||||||
if (!zcf->filename)
|
if (!zcf->filename)
|
||||||
break;
|
return -1;
|
||||||
|
|
||||||
frr_with_privs (lib_privs) {
|
frr_with_privs (lib_privs) {
|
||||||
fd = open(zcf->filename, flags | O_WRONLY | O_APPEND |
|
fd = open(zcf->filename, flags | O_WRONLY | O_APPEND |
|
||||||
@ -924,7 +929,7 @@ static int zlog_5424_open(struct zlog_cfg_5424 *zcf, int sock_type)
|
|||||||
flog_err_sys(EC_LIB_SYSTEM_CALL,
|
flog_err_sys(EC_LIB_SYSTEM_CALL,
|
||||||
"could not open log file %pSE: %m",
|
"could not open log file %pSE: %m",
|
||||||
zcf->filename);
|
zcf->filename);
|
||||||
break;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
frr_with_privs (lib_privs) {
|
frr_with_privs (lib_privs) {
|
||||||
@ -952,11 +957,11 @@ static int zlog_5424_open(struct zlog_cfg_5424 *zcf, int sock_type)
|
|||||||
flog_err_sys(EC_LIB_SYSTEM_CALL,
|
flog_err_sys(EC_LIB_SYSTEM_CALL,
|
||||||
"could not open or create log file %pSE: %m",
|
"could not open or create log file %pSE: %m",
|
||||||
zcf->filename);
|
zcf->filename);
|
||||||
break;
|
return -1;
|
||||||
|
|
||||||
case ZLOG_5424_DST_UNIX:
|
case ZLOG_5424_DST_UNIX:
|
||||||
if (!zcf->filename)
|
if (!zcf->filename)
|
||||||
break;
|
return -1;
|
||||||
|
|
||||||
memset(&sa, 0, sizeof(sa));
|
memset(&sa, 0, sizeof(sa));
|
||||||
sa.sun_family = AF_UNIX;
|
sa.sun_family = AF_UNIX;
|
||||||
@ -988,6 +993,7 @@ static int zlog_5424_open(struct zlog_cfg_5424 *zcf, int sock_type)
|
|||||||
"could not connect to log unix path %pSE: %m",
|
"could not connect to log unix path %pSE: %m",
|
||||||
zcf->filename);
|
zcf->filename);
|
||||||
need_reconnect = true;
|
need_reconnect = true;
|
||||||
|
/* no return -1 here, trigger retry code below */
|
||||||
} else {
|
} else {
|
||||||
/* datagram sockets are connectionless, restarting
|
/* datagram sockets are connectionless, restarting
|
||||||
* the receiver may lose some packets but will resume
|
* the receiver may lose some packets but will resume
|
||||||
|
Loading…
Reference in New Issue
Block a user