From: Maxim Mamontov Date: Mon, 9 Jun 2014 08:17:33 +0000 (+0300) Subject: More fixes after cppcheck. X-Git-Tag: 2.409~307 X-Git-Url: https://git.stg.codes/stg.git/commitdiff_plain/4a89beb9494451304e34e9a8e226936ac465c536 More fixes after cppcheck. --- diff --git a/projects/rlm_stg/iface.cpp b/projects/rlm_stg/iface.cpp index 741017b5..a74f3259 100644 --- a/projects/rlm_stg/iface.cpp +++ b/projects/rlm_stg/iface.cpp @@ -25,10 +25,10 @@ const STG_PAIR * stgPostAuthImpl(const char * userName, const char * serviceType return STG_CLIENT_ST::Get().PostAuth(userName, serviceType); } -const STG_PAIR * stgPreAcctImpl(const char * userName, const char * serviceType) +/*const STG_PAIR * stgPreAcctImpl(const char * userName, const char * serviceType) { return STG_CLIENT_ST::Get().PreAcct(userName, serviceType); -} +}*/ const STG_PAIR * stgAccountingImpl(const char * userName, const char * serviceType, const char * statusType, const char * sessionId) { diff --git a/projects/rlm_stg/iface.h b/projects/rlm_stg/iface.h index 57bb9f42..831c3123 100644 --- a/projects/rlm_stg/iface.h +++ b/projects/rlm_stg/iface.h @@ -13,7 +13,7 @@ int stgInstantiateImpl(const char * server, uint16_t port, const char * password const STG_PAIR * stgAuthorizeImpl(const char * userName, const char * serviceType); const STG_PAIR * stgAuthenticateImpl(const char * userName, const char * serviceType); const STG_PAIR * stgPostAuthImpl(const char * userName, const char * serviceType); -const STG_PAIR * stgPreAcctImpl(const char * userName, const char * serviceType); +/*const STG_PAIR * stgPreAcctImpl(const char * userName, const char * serviceType);*/ const STG_PAIR * stgAccountingImpl(const char * userName, const char * serviceType, const char * statusType, const char * sessionId); void deletePairs(const STG_PAIR * pairs); diff --git a/projects/rlm_stg/rlm_stg.c b/projects/rlm_stg/rlm_stg.c index 3eb913dc..e1caf575 100644 --- a/projects/rlm_stg/rlm_stg.c +++ b/projects/rlm_stg/rlm_stg.c @@ -103,8 +103,6 @@ static int stg_instantiate(CONF_SECTION *conf, void **instance) */ static int stg_authorize(void *, REQUEST *request) { - VALUE_PAIR * pwd; - VALUE_PAIR * svc; const STG_PAIR * pairs; const STG_PAIR * pair; size_t count = 0; @@ -120,7 +118,7 @@ static int stg_authorize(void *, REQUEST *request) DEBUG("rlm_stg: stg_authorize() request password field: '%s'", request->password->vp_strvalue); } // Here we need to define Framed-Protocol - svc = pairfind(request->packet->vps, PW_SERVICE_TYPE); + VALUE_PAIR * svc = pairfind(request->packet->vps, PW_SERVICE_TYPE); if (svc) { DEBUG("rlm_stg: stg_authorize() Service-Type defined as '%s'", svc->vp_strvalue); pairs = stgAuthorizeImpl((const char *)request->username->vp_strvalue, (const char *)svc->vp_strvalue); @@ -135,7 +133,7 @@ static int stg_authorize(void *, REQUEST *request) pair = pairs; while (!emptyPair(pair)) { - pwd = pairmake(pair->key, pair->value, T_OP_SET); + VALUE_PAIR * pwd = pairmake(pair->key, pair->value, T_OP_SET); pairadd(&request->config_items, pwd); DEBUG("Adding pair '%s': '%s'", pair->key, pair->value); ++pair; @@ -154,8 +152,6 @@ static int stg_authorize(void *, REQUEST *request) */ static int stg_authenticate(void *, REQUEST *request) { - VALUE_PAIR * svc; - VALUE_PAIR * pwd; const STG_PAIR * pairs; const STG_PAIR * pair; size_t count = 0; @@ -164,7 +160,7 @@ static int stg_authenticate(void *, REQUEST *request) DEBUG("rlm_stg: stg_authenticate()"); - svc = pairfind(request->packet->vps, PW_SERVICE_TYPE); + VALUE_PAIR * svc = pairfind(request->packet->vps, PW_SERVICE_TYPE); if (svc) { DEBUG("rlm_stg: stg_authenticate() Service-Type defined as '%s'", svc->vp_strvalue); pairs = stgAuthenticateImpl((const char *)request->username->vp_strvalue, (const char *)svc->vp_strvalue); @@ -179,7 +175,7 @@ static int stg_authenticate(void *, REQUEST *request) pair = pairs; while (!emptyPair(pair)) { - pwd = pairmake(pair->key, pair->value, T_OP_SET); + VALUE_PAIR * pwd = pairmake(pair->key, pair->value, T_OP_SET); pairadd(&request->reply->vps, pwd); ++pair; ++count; @@ -209,10 +205,6 @@ static int stg_preacct(void *, REQUEST *) */ static int stg_accounting(void *, REQUEST * request) { - VALUE_PAIR * sttype; - VALUE_PAIR * svc; - VALUE_PAIR * sessid; - VALUE_PAIR * pwd; const STG_PAIR * pairs; const STG_PAIR * pair; size_t count = 0; @@ -221,9 +213,9 @@ static int stg_accounting(void *, REQUEST * request) DEBUG("rlm_stg: stg_accounting()"); - svc = pairfind(request->packet->vps, PW_SERVICE_TYPE); - sessid = pairfind(request->packet->vps, PW_ACCT_SESSION_ID); - sttype = pairfind(request->packet->vps, PW_ACCT_STATUS_TYPE); + VALUE_PAIR * svc = pairfind(request->packet->vps, PW_SERVICE_TYPE); + VALUE_PAIR * sessid = pairfind(request->packet->vps, PW_ACCT_SESSION_ID); + VALUE_PAIR * sttype = pairfind(request->packet->vps, PW_ACCT_STATUS_TYPE); if (!sessid) { DEBUG("rlm_stg: stg_accounting() Acct-Session-ID undefined"); @@ -237,7 +229,7 @@ static int stg_accounting(void *, REQUEST * request) pairs = stgAccountingImpl((const char *)request->username->vp_strvalue, (const char *)svc->vp_strvalue, (const char *)sttype->vp_strvalue, (const char *)sessid->vp_strvalue); } else { DEBUG("rlm_stg: stg_accounting() Service-Type undefined"); - pairs = stgAccountingImpl((const char *)request->username->vp_strvalue, (const char *)svc->vp_strvalue, (const char *)sttype->vp_strvalue, (const char *)sessid->vp_strvalue); + pairs = stgAccountingImpl((const char *)request->username->vp_strvalue, "", (const char *)sttype->vp_strvalue, (const char *)sessid->vp_strvalue); } } else { DEBUG("rlm_stg: stg_accounting() Acct-Status-Type := NULL"); @@ -250,7 +242,7 @@ static int stg_accounting(void *, REQUEST * request) pair = pairs; while (!emptyPair(pair)) { - pwd = pairmake(pair->key, pair->value, T_OP_SET); + VALUE_PAIR * pwd = pairmake(pair->key, pair->value, T_OP_SET); pairadd(&request->reply->vps, pwd); ++pair; ++count; @@ -286,8 +278,6 @@ static int stg_checksimul(void *, REQUEST *request) static int stg_postauth(void *, REQUEST *request) { - VALUE_PAIR * svc; - VALUE_PAIR * pwd; const STG_PAIR * pairs; const STG_PAIR * pair; size_t count = 0; @@ -296,7 +286,7 @@ static int stg_postauth(void *, REQUEST *request) DEBUG("rlm_stg: stg_postauth()"); - svc = pairfind(request->packet->vps, PW_SERVICE_TYPE); + VALUE_PAIR * svc = pairfind(request->packet->vps, PW_SERVICE_TYPE); if (svc) { DEBUG("rlm_stg: stg_postauth() Service-Type defined as '%s'", svc->vp_strvalue); @@ -312,7 +302,7 @@ static int stg_postauth(void *, REQUEST *request) pair = pairs; while (!emptyPair(pair)) { - pwd = pairmake(pair->key, pair->value, T_OP_SET); + VALUE_PAIR * pwd = pairmake(pair->key, pair->value, T_OP_SET); pairadd(&request->reply->vps, pwd); ++pair; ++count; diff --git a/projects/sgauthstress/proto.cpp b/projects/sgauthstress/proto.cpp index 692c6946..2fd03140 100644 --- a/projects/sgauthstress/proto.cpp +++ b/projects/sgauthstress/proto.cpp @@ -389,11 +389,8 @@ bool PROTO::INFO_Proc(const void * buffer, USER * user) return true; } -bool PROTO::ERR_Proc(const void * buffer, USER * user) +bool PROTO::ERR_Proc(const void * /*buffer*/, USER * user) { -const ERR_8 * packet = static_cast(buffer); -const char * ptr = static_cast(buffer); - //uint32_t len = packet->len; #ifdef ARCH_BE @@ -510,7 +507,6 @@ hdr.protoVer[0] = 0; hdr.protoVer[1] = 8; // IA_PROTO_VER unsigned char buffer[2048]; -memset(buffer, 0, sizeof(buffer)); memcpy(buffer, packet, length); memcpy(buffer, &hdr, sizeof(hdr)); diff --git a/projects/stargazer/plugins/authorization/stress/stress.cpp b/projects/stargazer/plugins/authorization/stress/stress.cpp index 39e74b0d..6473b57e 100644 --- a/projects/stargazer/plugins/authorization/stress/stress.cpp +++ b/projects/stargazer/plugins/authorization/stress/stress.cpp @@ -158,7 +158,7 @@ users_iter = usersList.begin(); while (users_iter != usersList.end()) { Authorize(*users_iter); - users_iter++; + ++users_iter; } //isRunning = true; @@ -331,7 +331,7 @@ while (users_iter != usersList.end()) printfd(__FILE__, "User removed from list %s\n", u->GetLogin().c_str()); break; } - users_iter++; + ++users_iter; } } //----------------------------------------------------------------------------- @@ -343,8 +343,7 @@ return -1; //----------------------------------------------------------------------------- void * AUTH_STRESS::Run(void * d) { -AUTH_STRESS * ia; -ia = (AUTH_STRESS *)d; +AUTH_STRESS * ia = static_cast(d); ia->isRunning = true; @@ -367,7 +366,7 @@ while (ia->nonstop) printfd(__FILE__, "AUTH_STRESS::Unauthorize - user: '%s'\n", (*users_iter)->GetLogin().c_str()); } - users_iter++; + ++users_iter; } sleep(1); diff --git a/projects/stargazer/plugins/authorization/stress/stress.h b/projects/stargazer/plugins/authorization/stress/stress.h index fe9ccd9d..83ab3231 100644 --- a/projects/stargazer/plugins/authorization/stress/stress.h +++ b/projects/stargazer/plugins/authorization/stress/stress.h @@ -46,6 +46,7 @@ class AUTH_STRESS; template class CHG_BEFORE_NOTIFIER: public PROPERTY_NOTIFIER_BASE { public: + CHG_BEFORE_NOTIFIER() : auth(NULL) {} void Notify(const varParamType & oldValue, const varParamType & newValue); void SetUser(USER_PTR u) { user = u; } USER_PTR GetUser() {return user; } @@ -59,6 +60,7 @@ private: template class CHG_AFTER_NOTIFIER: public PROPERTY_NOTIFIER_BASE { public: + CHG_AFTER_NOTIFIER() : auth(NULL) {} void Notify(const varParamType & oldValue, const varParamType & newValue); void SetUser(USER_PTR u) { user = u; } USER_PTR GetUser() {return user; } @@ -132,7 +134,7 @@ private: class ADD_USER_NONIFIER: public NOTIFIER_BASE { public: - ADD_USER_NONIFIER() {} + ADD_USER_NONIFIER() : auth(NULL) {} virtual ~ADD_USER_NONIFIER() {} void SetAuthorizator(AUTH_STRESS * a) { auth = a; } @@ -147,7 +149,7 @@ private: class DEL_USER_NONIFIER: public NOTIFIER_BASE { public: - DEL_USER_NONIFIER() {} + DEL_USER_NONIFIER() : auth(NULL) {} virtual ~DEL_USER_NONIFIER() {} void SetAuthorizator(AUTH_STRESS * a) { auth = a; } diff --git a/projects/stargazer/plugins/capture/cap_debug/Makefile b/projects/stargazer/plugins/capture/cap_debug/Makefile index 48b0e870..e96d69bc 100644 --- a/projects/stargazer/plugins/capture/cap_debug/Makefile +++ b/projects/stargazer/plugins/capture/cap_debug/Makefile @@ -8,13 +8,9 @@ PROG = mod_cap_debug.so SRCS = ./debug_cap.cpp \ ./checksum.c \ - ./icmp.c \ ./ip.c \ - ./misc.c \ ./packet.c \ - ./socket.c \ - ./tcp.c \ - ./udp.c + ./tcp.c STGLIBS = common diff --git a/projects/stargazer/plugins/capture/cap_debug/debug_cap.cpp b/projects/stargazer/plugins/capture/cap_debug/debug_cap.cpp index 480ef202..0ba91bbb 100644 --- a/projects/stargazer/plugins/capture/cap_debug/debug_cap.cpp +++ b/projects/stargazer/plugins/capture/cap_debug/debug_cap.cpp @@ -28,19 +28,24 @@ $Date: 2009/03/19 20:03:35 $ $Author: faust $ */ -#include +#include "debug_cap.h" + +#include "libpal.h" + +#include "stg/plugin_creator.h" +#include "stg/traffcounter.h" +#include "stg/common.h" + +#include +#include + #include -#include #include -#include #include #include #include -#include "libpal.h" -#include "stg/plugin_creator.h" -#include "stg/traffcounter.h" -#include "debug_cap.h" +extern volatile time_t stgTime; //----------------------------------------------------------------------------- void WriteStat(uint32_t u, uint32_t d) @@ -61,11 +66,11 @@ namespace PLUGIN_CREATOR cdc; } -extern "C" BASE_PLUGIN * GetPlugin(); +extern "C" PLUGIN * GetPlugin(); //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- -BASE_PLUGIN * GetPlugin() +PLUGIN * GetPlugin() { return cdc.GetPlugin(); } @@ -85,9 +90,10 @@ return "cap_debug v.0.01a"; } //----------------------------------------------------------------------------- DEBUG_CAP::DEBUG_CAP() + : nonstop(false), + isRunning(false), + traffCnt(NULL) { -isRunning = false; -nonstop = false; } //----------------------------------------------------------------------------- void DEBUG_CAP::SetTraffcounter(TRAFFCOUNTER * tc) @@ -132,7 +138,7 @@ for (i = 0; i < 25; i++) if (!isRunning) break; - stgUsleep(200000); + usleep(200000); //printf("."); } @@ -162,7 +168,7 @@ void * DEBUG_CAP::Run1(void * data) { printfd(__FILE__, "=====================| pid: %d |===================== \n", getpid()); -DEBUG_CAP * dc = (DEBUG_CAP *)data; +DEBUG_CAP * dc = static_cast(data); dc->isRunning = true; RAW_PACKET rp; @@ -183,24 +189,20 @@ int dsize; t = stgTime; tm = localtime(&t); int min = tm->tm_min; -int sec = tm->tm_sec; char cliIP[20]; char srvIP[20]; -char trashIP1[20]; -char trashIP2[20]; while (dc->nonstop) { for (int i = 8; i <= 252; i++) { - usize = random()%100 + 100; - dsize = random()%500 + 900; - + dsize = random()%500 + 900; + for (int j = 2; j < 11; j++) { - sprintf(cliIP, "192.168.%d.%d", j, i); + sprintf(cliIP, "192.168.%d.%d", j, i); sprintf(srvIP, "10.1.%d.%d", random()%8, 1); rp = MakeTCPPacket(srvIP, cliIP, 80, random()%2 + 2000, dsize); @@ -235,7 +237,7 @@ void * DEBUG_CAP::Run2(void * data) { printfd(__FILE__, "=====================| pid: %d |===================== \n", getpid()); -DEBUG_CAP * dc = (DEBUG_CAP *)data; +DEBUG_CAP * dc = static_cast(data); dc->isRunning = true; RAW_PACKET rp; @@ -315,7 +317,7 @@ void * DEBUG_CAP::Run3(void * data) { printfd(__FILE__, "=====================| pid: %d |===================== \n", getpid()); -DEBUG_CAP * dc = (DEBUG_CAP *)data; +DEBUG_CAP * dc = static_cast(data); dc->isRunning = true; RAW_PACKET rp; @@ -323,7 +325,6 @@ rp = MakeTCPPacket("192.168.1.1", "192.168.1.21", 255, 255, 200); int a = 0; sleep(3); -struct tm * tm; time_t t; uint32_t u = 0; uint32_t d = 0; @@ -334,7 +335,6 @@ int usize = 200; int dsize = 1500; t = stgTime; -tm = localtime(&t); char cliIP[20]; char srvIP1[20]; @@ -497,7 +497,6 @@ if (pkt_free(&pkt)) printfd(__FILE__, "pkt_free error!\n"); } rp.dataLen = -1; -strcpy(rp.iface, "eth0"); return rp; } //----------------------------------------------------------------------------- diff --git a/projects/stargazer/plugins/capture/cap_debug/icmp.c b/projects/stargazer/plugins/capture/cap_debug/icmp.c deleted file mode 100644 index abbaef10..00000000 --- a/projects/stargazer/plugins/capture/cap_debug/icmp.c +++ /dev/null @@ -1,154 +0,0 @@ -/* $Id: icmp.c,v 1.1 2005/12/12 18:14:22 nobunaga Exp $ - -Copyright (C) 2002 Marc Kirchner - -This library is free software; you can redistribute it and/or -modify it under the terms of the GNU Lesser General Public -License as published by the Free Software Foundation; either -version 2.1 of the License, or (at your option) any later version. - -This library is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public -License along with this library; if not, write to the Free Software -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -#include "libpal.h" - -int -pkt_icmp_header(struct packet *pkt, unsigned char type, unsigned char code, unsigned short int checksum) -{ - - struct icmp *icmp; - if (pkt) { - icmp = (struct icmp *) pkt->pkt_ptr; - icmp->icmp_type = type; - icmp->icmp_code = code; - icmp->icmp_cksum = htons(checksum); - return 0; - } else - return EPKTINVALPTR; -} - -int pkt_icmp_addr_mask(struct packet *pkt, unsigned short int id, unsigned short int seqno, unsigned int mask, char *cmask) -{ - struct icmp *icmp; - struct in_addr inetaddr; - - if (pkt) { - icmp = (struct icmp *)pkt->pkt_ptr; - } else - return EPKTINVALPTR; - icmp->icmp_id = htons(id); - icmp->icmp_seq = htons(seqno); - if (!cmask) { - icmp->icmp_mask = htons(mask); - } else { - if (inet_aton(cmask, &inetaddr) != 0) { - icmp->icmp_mask = inetaddr.s_addr; - } else - return EERRNO; - } - return 0; -} - -int -pkt_icmp_cksum(struct packet *pkt, unsigned int len) -{ - struct icmp *icmp; - - if (!pkt) - return EPKTINVALPTR; - - icmp = (struct icmp *) pkt->pkt_ptr; - icmp->icmp_cksum = 0; - icmp->icmp_cksum = in_cksum((unsigned short *)icmp, len); - return 0; -} - -int -pkt_icmp_dest_unreach(struct packet *pkt, unsigned int unused) -{ - struct icmp *icmp; - - if (pkt) { - icmp = (struct icmp *)pkt->pkt_ptr; - } else - return EPKTINVALPTR; - icmp->icmp_void = htons(unused); - return 0; -} - -int -pkt_icmp_source_quench(struct packet *pkt, unsigned int unused) -{ - struct icmp *icmp; - - if (pkt) { - icmp = (struct icmp *)pkt->pkt_ptr; - } else - return EPKTINVALPTR; - icmp->icmp_void = htons(unused); - return 0; -} - -int -pkt_icmp_redirect(struct packet *pkt, unsigned int routerip, char *crouterip) -{ - struct icmp *icmp; - struct in_addr inetaddr; - - if (pkt) { - icmp = (struct icmp *)pkt->pkt_ptr; - } else { - return EPKTINVALPTR; - } - if (crouterip) { - if (inet_aton(crouterip, &inetaddr) != 0) { - icmp->icmp_gwaddr = inetaddr; - } else - return EERRNO; - } else { - inetaddr.s_addr = htons(routerip); - icmp->icmp_gwaddr = inetaddr; - } - return 0; -} - -int -pkt_icmp_echo(struct packet *pkt, unsigned short int id, unsigned short int seqno, void *data, size_t data_len) -{ - struct icmp *icmp; - - if (pkt) { - icmp = (struct icmp *) pkt->pkt_ptr; - } else - return EPKTINVALPTR; - icmp->icmp_id = htons(id); - icmp->icmp_seq = htons(seqno); - if (data) { - memcpy(icmp->icmp_data, data, data_len); - } - return 0; -} - -int -pkt_icmp_timestamp(struct packet *pkt, unsigned short int id, unsigned short int seqno, unsigned int ts_otime, unsigned int ts_rtime, unsigned int ts_ttime) -{ - struct icmp *icmp; - - if (pkt) - icmp = (struct icmp *) pkt->pkt_ptr; - else - return EPKTINVALPTR; - icmp->icmp_id = htons(id); - icmp->icmp_seq = htons(seqno); - icmp->icmp_otime = htons(ts_otime); - icmp->icmp_rtime = htons(ts_rtime); - icmp->icmp_ttime = htons(ts_ttime); - return 0; -} diff --git a/projects/stargazer/plugins/capture/cap_debug/ip.c b/projects/stargazer/plugins/capture/cap_debug/ip.c index bc632f37..a2627177 100644 --- a/projects/stargazer/plugins/capture/cap_debug/ip.c +++ b/projects/stargazer/plugins/capture/cap_debug/ip.c @@ -53,72 +53,3 @@ pkt_ip_header(struct packet *pkt, return 0; } - -int -pkt_ip_option_header(struct packet *pkt, unsigned char type, unsigned char len, unsigned char ptr, unsigned char oflw_flg, void *optval, size_t optlen) -{ - unsigned char *vp; - - if (!pkt) - return EPKTINVALPTR; - - vp = pkt->pkt_ptr; - *vp = type; - switch (type) { - case PKT_IP_OPT_END: - break; - case PKT_IP_OPT_NOP: - break; - case PKT_IP_OPT_SEC: - if ((pkt->pkt_pos + 2 + optlen) <= pkt->pkt_size) { - *(vp+1) = len; - memcpy((void*)(vp+2), optval, optlen); - } else { - return EPKTRANGE; - } - break; - case PKT_IP_OPT_RR: - case PKT_IP_OPT_LSRR: - case PKT_IP_OPT_SSRR: - case PKT_IP_OPT_SID: - if ((pkt->pkt_pos + 3 + optlen) <= pkt->pkt_size) { - *(vp+1) = len; - *(vp+2) = ptr; - memcpy((void*)(vp+3), optval, optlen); - } else { - return EPKTRANGE; - } - break; - case PKT_IP_OPT_TS: - if ((pkt->pkt_pos + 4 + optlen) <= pkt->pkt_size) { - *(vp+1) = len; - *(vp+2) = ptr; - *(vp+3) = oflw_flg; - memcpy((void*)(vp+4), optval, optlen); - } else { - return EPKTRANGE; - } - break; - default: - return EPKTUNKNOWNTYPE; - } - return PKTOK; -} - -int -pkt_ip_cksum(struct packet *pkt) -{ - /* - * checksum should be calculated by kernel - * when we are using SOCK_RAW access. - */ - struct ip *ip; - - if (!pkt) - return EPKTINVALPTR; - - ip = (struct ip *) pkt->pkt_ptr; - ip->ip_sum = 0; - ip->ip_sum = in_cksum((unsigned short *)ip, sizeof(struct ip)); - return 0; -} diff --git a/projects/stargazer/plugins/capture/cap_debug/libpal.h b/projects/stargazer/plugins/capture/cap_debug/libpal.h index cbd239fc..fa28d8e8 100644 --- a/projects/stargazer/plugins/capture/cap_debug/libpal.h +++ b/projects/stargazer/plugins/capture/cap_debug/libpal.h @@ -78,47 +78,16 @@ int pkt_init(struct packet *pkt, unsigned long type, unsigned int size); int pkt_free(struct packet *pkt); /* pointer movement */ -int pkt_set_actptr(struct packet *pkt, unsigned int bytepos); int pkt_move_actptr(struct packet *pkt, int relmov); -/* raw data */ -int pkt_add_systimestamp(struct packet *pkt); -int pkt_add_data(struct packet *pkt, char *data, size_t data_len); -int pkt_resize(struct packet *pkt, unsigned int newsize); - -/* socket operations */ -int pkt_socket_open(struct pkt_socket *sck, int type); -int pkt_socket_close(struct pkt_socket *sck); -int pkt_socket_prepare(struct pkt_socket *sck, char *daddr); -int pkt_socket_setopt(struct pkt_socket *sck, int level, int optname, void *optval, socklen_t optlen); - -/* sending */ -int pkt_send(struct packet *pkt, struct pkt_socket *sck); - /* IP */ int pkt_ip_header(struct packet *pkt, unsigned int iphdr_len, unsigned int version, unsigned char tos, unsigned short int total_len, unsigned short int id, unsigned short int frag_off /* 3bit flag, 13bit offset */, unsigned char ttl, unsigned char protocol, unsigned short int cksum, unsigned int saddr, unsigned int daddr); -int pkt_ip_cksum(struct packet *pkt); -int pkt_ip_option_header(struct packet *pkt, unsigned char type, unsigned char len, unsigned char ptr, unsigned char oflw_flg, void *optval, size_t optlen); /* TCP */ int pkt_tcp_header(struct packet *pkt, unsigned short int sport, unsigned short int dport, unsigned int seq, unsigned int ackseq, unsigned char headerlen, unsigned char reserved, unsigned char flags, unsigned short window, unsigned short int checksum, unsigned short int urgent); int pkt_tcp_cksum(struct packet *pkt, char *saddr, char *daddr, unsigned int tcp_pkt_size); int pkt_tcp_option(struct packet *pkt, unsigned char kind, unsigned char len, void *optval, size_t optlen); -/* UDP */ -int pkt_udp_header(struct packet *pkt, unsigned short int sport, unsigned short int dport, unsigned short int udp_total_len, unsigned short int checksum); -int pkt_udp_cksum(struct packet *pkt, char *saddr, char *daddr, unsigned int udp_total_len); - -/* ICMP */ -int pkt_icmp_header(struct packet *pkt, unsigned char type, unsigned char code, unsigned short int checksum); -int pkt_icmp_cksum(struct packet *pkt, unsigned int len); -int pkt_icmp_addr_mask(struct packet *pkt, unsigned short int id, unsigned short int seqno, unsigned int mask, char *cmask); -int pkt_icmp_dest_unreach(struct packet *pkt, unsigned int unused); -int pkt_icmp_source_quench(struct packet *pkt, unsigned int unused); -int pkt_icmp_redirect(struct packet *pkt, unsigned int routerip, char *crouterip); -int pkt_icmp_echo(struct packet *pkt, unsigned short int id, unsigned short int seqno, void *data, size_t data_len); -int pkt_icmp_timestamp(struct packet *pkt, unsigned short int id, unsigned short int seqno, unsigned int ts_otime, unsigned int ts_rtime, unsigned int ts_ttime); - /* functions that might be useful and might be added some day ... int pkt_shift_data(struct packet *pkt, unsigned int from, unsigned int to, unsigned int len); int pkt_tcp_change_seqno(int rel_seq, int rel_ackseq); diff --git a/projects/stargazer/plugins/capture/cap_debug/misc.c b/projects/stargazer/plugins/capture/cap_debug/misc.c deleted file mode 100644 index bd0b06a7..00000000 --- a/projects/stargazer/plugins/capture/cap_debug/misc.c +++ /dev/null @@ -1,41 +0,0 @@ -/* $Id: misc.c,v 1.1 2005/12/12 18:14:22 nobunaga Exp $ - -Copyright (C) 2002 Marc Kirchner - -This library is free software; you can redistribute it and/or -modify it under the terms of the GNU Lesser General Public -License as published by the Free Software Foundation; either -version 2.1 of the License, or (at your option) any later version. - -This library is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public -License along with this library; if not, write to the Free Software -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -#include "libpal.h" - -/* -<++doc++> -@name int pkt_add_systimestamp(struct packet *pkt) -@desc Adds a system timestamp (struct timeval) at the position where pkt->pkt_ptr points to. -@param pkt packet into which a timestamp with the current system time will be added. -<--doc--> -*/ -int -pkt_add_systimestamp(struct packet *pkt) -{ - if (!pkt) - return EPKTINVALPTR; - if (pkt->pkt_size < (pkt->pkt_pos + sizeof(struct timeval))) - return EPKTRANGE; - if (gettimeofday((struct timeval *)pkt->pkt_ptr, NULL) == 0) - return 0; - else - return EERRNO; -} - diff --git a/projects/stargazer/plugins/capture/cap_debug/packet.c b/projects/stargazer/plugins/capture/cap_debug/packet.c index 6b76f005..9405818e 100644 --- a/projects/stargazer/plugins/capture/cap_debug/packet.c +++ b/projects/stargazer/plugins/capture/cap_debug/packet.c @@ -65,28 +65,6 @@ pkt_free(struct packet *pkt) return EPKTINVALPTR; } -/* -<++doc++> -@name int pkt_set_actptr(struct packet *pkt, unsigned int bytepos) -@desc This function sets the active pointer position inside the packet. -@param pkt the packet whose active ptr is to be set -@param bytepos the byte position where to set the active ptr to, starting from 0 -<--doc--> -*/ - -int -pkt_set_actptr(struct packet *pkt, unsigned int bytepos) -{ - if (!pkt) - return EPKTINVALPTR; - if (bytepos > pkt->pkt_size) { - return EPKTRANGE; - } else { - pkt->pkt_ptr = pkt->pkt + bytepos; - return PKTOK; - } -} - /* <++doc++> @name int pkt_move_actptr(struct packet *pkt, int relmov) @@ -108,54 +86,3 @@ pkt_move_actptr(struct packet *pkt, int relmov) return PKTOK; } } - -/* -<++doc++> -@name int pkt_add_data(struct packet *pkt, char *data, size_t data_len) -@desc Adds supplied data at the current active ptr position of the given packet.This basically is a memcpy() wrapper function. -@param pkt data will be written into this packet -@param data a pointer to the data that shall be copied into the packet -@param data_len the amount of data (in bytes) that will be copied -<--doc--> -*/ -int -pkt_add_data(struct packet *pkt, char *data, size_t data_len) -{ - if (!pkt || !data) - return EPKTINVALPTR; - if (pkt->pkt_size >= (pkt->pkt_pos + data_len)) { - memcpy(pkt->pkt_ptr, data, data_len); - return 0; - } else - return EPKTRANGE; -} - -/* -<++doc++> -@name int pkt_resize(struct packet *pkt, unsigned int newsize) -@desc The given packet will be resized to newsize -@param pkt the packet to resize -@param newsize the new size of the packet -<--doc--> -*/ -int -pkt_resize(struct packet *pkt, unsigned int newsize) -{ - unsigned char *newpkt; - - if (!pkt) - return EPKTINVALPTR; - - if ((newpkt = (unsigned char *) malloc(newsize)) != NULL) { - memset(newpkt, 0, newsize); - memcpy(newpkt, pkt->pkt, (pkt->pkt_size < newsize ? pkt->pkt_size : newsize)); - pkt->pkt_size = newsize; - pkt->pkt_ptr = newpkt; - pkt->pkt_pos = 0; - /* free old mem */ - free (pkt->pkt); - pkt->pkt = newpkt; - return 0; - } else - return EERRNO; -} diff --git a/projects/stargazer/plugins/capture/cap_debug/socket.c b/projects/stargazer/plugins/capture/cap_debug/socket.c deleted file mode 100644 index b7044bc6..00000000 --- a/projects/stargazer/plugins/capture/cap_debug/socket.c +++ /dev/null @@ -1,163 +0,0 @@ -/* $Id: socket.c,v 1.1 2005/12/12 18:14:22 nobunaga Exp $ - -Copyright (C) 2002 Marc Kirchner - -This library is free software; you can redistribute it and/or -modify it under the terms of the GNU Lesser General Public -License as published by the Free Software Foundation; either -version 2.1 of the License, or (at your option) any later version. - -This library is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public -License along with this library; if not, write to the Free Software -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -#include "libpal.h" - -/* -<++doc++> -@name int pkt_socket_open(struct pkt_socket *sck, int type) -@desc Opens a packet socket. This is necessary to be able to send any packages. -@param sck pointer to a pkt_socket structure -@param type The type of the socket. Possible values are PKT_RAW (to open a raw socket. IP, TCP/UDP and application header have to be forged before sending) , PKT_STREAM, PKT_DGRAM. STREAM and DGRAM are supported by this function, but other function do not care. -<--doc--> -*/ -int -pkt_socket_open(struct pkt_socket *sck, int type) -{ - int proto; - int iphdrincl = 1; - int ret = 0; - - if (!sck) - return EPKTINVALPTR; - - /* get mem for sockaddr structure */ - if ((sck->sckad = (struct sockaddr_in *) malloc (sizeof(struct sockaddr_in))) == NULL) { - return -1; - } - sck->sckad_len = sizeof(struct sockaddr_in); - memset(sck->sckad, 0, sck->sckad_len); - - /* except for raw sockets, proto is set to 0 */ - /* (Stevens, UNP 2nd ed., 1998) */ - switch (type) { - case PKT_RAW: - proto = IPPROTO_RAW; - break; - default: - proto = 0; - break; - } - if ((sck->rawfd = socket(AF_INET, type, proto)) == -1) { - return -1; - } - if (type == PKT_RAW) { - if ((ret = setsockopt(sck->rawfd, IPPROTO_IP, IP_HDRINCL, (const void *) &iphdrincl, sizeof(iphdrincl))) < 0) { - return -1; - } - } - return 0; -} - - -/* -<++doc++> -@name int pkt_socket_close(struct pkt_socket *sck) -@desc Closes a packet socket and frees used memory. -@param sck pointer to a pkt_socket structure -<--doc--> -*/ -int -pkt_socket_close(struct pkt_socket *sck) -{ - if (!sck) - return EPKTINVALPTR; - close(sck->rawfd); - free(sck->sckad); - sck->sckad=NULL; - return 0; -} - -/* -<++doc++> -@name int pkt_socket_prepare(struct pkt_socket *sck, char *daddr) -@desc this function is necessary to enable the kernel to determine the correct outgoing interface -@param sck pointer to a pkt_socket structure -@param daddr dotted-decimal destination IP address -<--doc--> -*/ -int -pkt_socket_prepare(struct pkt_socket *sck, char *daddr) -{ - /* - * this is necessary for the kernel to determine outgoing - * interface. - */ - - int ret = 0; - - if (!sck || !daddr) - return EPKTINVALPTR; - - /* set up sockaddr struct */ - memset(sck->sckad, 0, sck->sckad_len); - if ((ret = inet_pton(AF_INET, daddr, &(sck->sckad->sin_addr))) == 0) { - return -1; - } - sck->sckad->sin_family = AF_INET; - - /* - * i dont think we need to set the dest port... - */ - return 0; -} - -/* -<++doc++> -@name int pkt_socket_setopt(struct pkt_socket *sck, int level, int optname, void *optval, socklen_t optlen) -@desc this is basically a wrapper function for setsockopt(2) -@param sck pointer to a pkt_socket structure -@param level level the socket option will apply to (should be SOL_SOCKET) -@param optname option name, see sys/socket.h for values -@param optval new option value (for boolean options: 0=false) -@param optlen option value size (this is a value-result parameter!) -<--doc--> -*/ -int -pkt_socket_setopt(struct pkt_socket *sck, int level, - int optname, void *optval, socklen_t optlen) -{ - if (!sck) - return EPKTINVALPTR; - return (setsockopt(sck->rawfd, level, optname, optval, optlen)); -} - - -/* -<++doc++> -@name int pkt_send(struct packet *pkt, struct pkt_socket *sck) -@desc sends the packet pkt unsing the socket sck -@param pkt pointer to a packet structure -@param sck pointer to a pkt_socket structure -<--doc--> -*/ -int -pkt_send(struct packet *pkt, struct pkt_socket *sck) -{ - int ret = 0; - - if (!pkt || !sck) - return EPKTINVALPTR; - - /* no sendto-flags support */ - if ((ret = sendto(sck->rawfd, pkt->pkt, pkt->pkt_size, 0, (struct sockaddr *) sck->sckad, sck->sckad_len)) == -1) { - return -1; - } - return 0; -} diff --git a/projects/stargazer/plugins/capture/cap_debug/udp.c b/projects/stargazer/plugins/capture/cap_debug/udp.c deleted file mode 100644 index 238c95db..00000000 --- a/projects/stargazer/plugins/capture/cap_debug/udp.c +++ /dev/null @@ -1,82 +0,0 @@ -/* $Id: udp.c,v 1.1 2005/12/12 18:14:22 nobunaga Exp $ - -Copyright (C) 2002 Marc Kirchner - -This library is free software; you can redistribute it and/or -modify it under the terms of the GNU Lesser General Public -License as published by the Free Software Foundation; either -version 2.1 of the License, or (at your option) any later version. - -This library is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public -License along with this library; if not, write to the Free Software -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -#include "libpal.h" -#include "types.h" - -int -pkt_udp_header(struct packet *pkt, unsigned short int sport, unsigned short int dport, unsigned short int udp_total_len, unsigned short int checksum) -{ - struct udphdr *udp; - - if (!pkt) - return EPKTINVALPTR; - if (pkt->pkt_size >= (pkt->pkt_pos + sizeof(struct udphdr))) { - udp = (struct udphdr *) pkt->pkt_ptr; - udp->source = htons(sport); - udp->dest = htons(dport); - udp->len = htons(udp_total_len); - udp->check = htons(checksum); - return 0; - } else - return EPKTRANGE; -} - -int -pkt_udp_cksum(struct packet *pkt, char *saddr, char *daddr, - unsigned int udp_total_len) -{ - char *tosum; - struct pseudohdr *psh; - struct udphdr *udp; - unsigned short int check=0; - struct in_addr addr; - - if (!pkt || !saddr || !daddr) - return EPKTINVALPTR; - - if ((udp_total_len + pkt->pkt_pos) > pkt->pkt_size -1) - return EPKTRANGE; - - if ((tosum = (char *) malloc(udp_total_len+sizeof(struct pseudohdr))) != NULL) { - memset(tosum, 0, udp_total_len+sizeof(struct pseudohdr)); - psh = (struct pseudohdr *) tosum; - udp = (struct udphdr *) pkt->pkt_ptr; - - udp->check = 0; - - if (inet_pton(AF_INET, saddr, &addr) < 0) - return EERRNO; - psh->saddr = addr.s_addr; - if (inet_pton(AF_INET, daddr, &addr) < 0) - return EERRNO; - psh->daddr = addr.s_addr; - psh->zero = 0x00; - psh->protocol = IPPROTO_UDP; - psh->length = htons(udp_total_len); - - memcpy(tosum + sizeof(struct pseudohdr), udp, udp_total_len); - check = in_cksum((unsigned short *)tosum, udp_total_len + sizeof(struct pseudohdr)); - /* _no_ call to htons(), because tosum is in network byte order */ - udp->check = check == 0 ? 0xffff : check; - free(tosum); - return 0; - } else - return EERRNO; -} diff --git a/projects/stargazer/plugins/other/smux/utils.cpp b/projects/stargazer/plugins/other/smux/utils.cpp index 3160bc5f..0ea39bbb 100644 --- a/projects/stargazer/plugins/other/smux/utils.cpp +++ b/projects/stargazer/plugins/other/smux/utils.cpp @@ -48,27 +48,6 @@ OBJECT_IDENTIFIER_set_arcs(oi, arcs, sizeof(arcs[0]), static_cast( return true; } -std::string OI2String(OBJECT_IDENTIFIER_t * oi) -{ -std::string res; - -int arcs[1024]; -int count = OBJECT_IDENTIFIER_get_arcs(oi, arcs, sizeof(arcs[0]), 1024); - -if (count > 1024) - return ""; - -for (int i = 0; i < count; ++i) - { - res += "."; - std::string arc; - strprintf(&arc, "%d", arcs[i]); - res += arc; - } - -return res; -} - bool SendOpenPDU(int fd) { const char * description = "Stg SMUX Plugin"; diff --git a/projects/stargazer/plugins/other/smux/utils.h b/projects/stargazer/plugins/other/smux/utils.h index 27eb3bf1..52a3988b 100644 --- a/projects/stargazer/plugins/other/smux/utils.h +++ b/projects/stargazer/plugins/other/smux/utils.h @@ -8,7 +8,6 @@ #include "stg/GetResponse-PDU.h" bool String2OI(const std::string & str, OBJECT_IDENTIFIER_t * oi); -std::string OI2String(OBJECT_IDENTIFIER_t * oi); bool SendOpenPDU(int fd); bool SendClosePDU(int fd); bool SendRReqPDU(int fd); diff --git a/projects/stargazer/traffcounter_impl.cpp b/projects/stargazer/traffcounter_impl.cpp index 83c699f8..985de593 100644 --- a/projects/stargazer/traffcounter_impl.cpp +++ b/projects/stargazer/traffcounter_impl.cpp @@ -654,7 +654,7 @@ while (fgets(str, 1023, f)) continue; } - r = sscanf(str,"%s %s %s", tp, ta, td); + r = sscanf(str,"%100s %100s %100s", tp, ta, td); if (r != 3) { printfd(__FILE__, "TRAFFCOUNTER_IMPL::ReadRules() - Error in file '%s' at line %d. There must be 3 parameters.\n", rulesFileName.c_str(), lineNumber); diff --git a/stglibs/smux.lib/INTEGER.c b/stglibs/smux.lib/INTEGER.c index 9c8b9ed3..ba455f07 100644 --- a/stglibs/smux.lib/INTEGER.c +++ b/stglibs/smux.lib/INTEGER.c @@ -109,7 +109,6 @@ INTEGER__dump(asn_TYPE_descriptor_t *td, const INTEGER_t *st, asn_app_consume_by signed long accum; ssize_t wrote = 0; char *p; - int ret; /* * Advance buf pointer until the start of the value's body. @@ -130,6 +129,7 @@ INTEGER__dump(asn_TYPE_descriptor_t *td, const INTEGER_t *st, asn_app_consume_by if((size_t)(buf_end - buf) <= sizeof(accum)) { const asn_INTEGER_enum_map_t *el; size_t scrsize; + int ret; char *scr; if(buf == buf_end) { diff --git a/stglibs/smux.lib/NativeEnumerated.c b/stglibs/smux.lib/NativeEnumerated.c index e3af1ca4..3486cec1 100644 --- a/stglibs/smux.lib/NativeEnumerated.c +++ b/stglibs/smux.lib/NativeEnumerated.c @@ -142,7 +142,7 @@ NativeEnumerated_encode_uper(asn_TYPE_descriptor_t *td, asn_INTEGER_specifics_t *specs = (asn_INTEGER_specifics_t *)td->specifics; asn_enc_rval_t er; long native, value; - asn_per_constraint_t *ct; + asn_per_constraint_t *ct = NULL; int inext = 0; asn_INTEGER_enum_map_t key; asn_INTEGER_enum_map_t *kf; @@ -170,13 +170,13 @@ NativeEnumerated_encode_uper(asn_TYPE_descriptor_t *td, } value = kf - specs->value2enum; - if(ct->range_bits >= 0) { + if(ct && ct->range_bits >= 0) { int cmpWith = specs->extension ? specs->extension - 1 : specs->map_count; if(value >= cmpWith) inext = 1; } - if(ct->flags & APC_EXTENSIBLE) { + if(ct && ct->flags & APC_EXTENSIBLE) { if(per_put_few_bits(po, inext, 0)) _ASN_ENCODE_FAILED; ct = 0; diff --git a/stglibs/smux.lib/NativeInteger.c b/stglibs/smux.lib/NativeInteger.c index 34599f61..db234c8b 100644 --- a/stglibs/smux.lib/NativeInteger.c +++ b/stglibs/smux.lib/NativeInteger.c @@ -283,14 +283,13 @@ int NativeInteger_print(asn_TYPE_descriptor_t *td, const void *sptr, int ilevel, asn_app_consume_bytes_f *cb, void *app_key) { const long *native = (const long *)sptr; - char scratch[32]; /* Enough for 64-bit int */ - int ret; (void)td; /* Unused argument */ (void)ilevel; /* Unused argument */ if(native) { - ret = snprintf(scratch, sizeof(scratch), "%ld", *native); + char scratch[32]; /* Enough for 64-bit int */ + int ret = snprintf(scratch, sizeof(scratch), "%ld", *native); assert(ret > 0 && (size_t)ret < sizeof(scratch)); return (cb(scratch, ret, app_key) < 0) ? -1 : 0; } else { diff --git a/stglibs/smux.lib/OBJECT_IDENTIFIER.c b/stglibs/smux.lib/OBJECT_IDENTIFIER.c index b1666dc6..d0367f0f 100644 --- a/stglibs/smux.lib/OBJECT_IDENTIFIER.c +++ b/stglibs/smux.lib/OBJECT_IDENTIFIER.c @@ -182,7 +182,6 @@ OBJECT_IDENTIFIER__dump_arc(uint8_t *arcbuf, int arclen, int add, asn_app_consume_bytes_f *cb, void *app_key) { char scratch[64]; /* Conservative estimate */ unsigned long accum; /* Bits accumulator */ - char *p; /* Position in the scratch buffer */ if(OBJECT_IDENTIFIER_get_single_arc(arcbuf, arclen, add, &accum, sizeof(accum))) @@ -190,9 +189,8 @@ OBJECT_IDENTIFIER__dump_arc(uint8_t *arcbuf, int arclen, int add, if(accum) { ssize_t len; + char *p = scratch + sizeof(scratch); /* Position in the scratch buffer */ - /* Fill the scratch buffer in reverse. */ - p = scratch + sizeof(scratch); for(; accum; accum /= 10) *(--p) = (char)(accum % 10) + 0x30; /* Put a digit */ diff --git a/stglibs/smux.lib/OCTET_STRING.c b/stglibs/smux.lib/OCTET_STRING.c index 3a83bd98..9e9694b5 100644 --- a/stglibs/smux.lib/OCTET_STRING.c +++ b/stglibs/smux.lib/OCTET_STRING.c @@ -593,7 +593,6 @@ OCTET_STRING_encode_xer(asn_TYPE_descriptor_t *td, void *sptr, char *p = scratch; uint8_t *buf; uint8_t *end; - size_t i; if(!st || !st->buf) _ASN_ENCODE_FAILED; @@ -620,6 +619,7 @@ OCTET_STRING_encode_xer(asn_TYPE_descriptor_t *td, void *sptr, _ASN_CALLBACK(scratch, p-scratch); /* Dump the rest */ er.encoded += p - scratch; } else { + size_t i; for(i = 0; buf < end; buf++, i++) { if(!(i % 16) && (i || st->size > 16)) { _ASN_CALLBACK(scratch, p-scratch); @@ -1315,12 +1315,13 @@ OCTET_STRING_encode_uper(asn_TYPE_descriptor_t *td, asn_enc_rval_t er; int ct_extensible = ct->flags & APC_EXTENSIBLE; int inext = 0; /* Lies not within extension root */ - int sizeinunits = st->size; + int sizeinunits = 0; const uint8_t *buf; int ret; if(!st || !st->buf) _ASN_ENCODE_FAILED; + sizeinunits = st->size; if(unit_bits == 1) { ASN_DEBUG("BIT STRING of %d bytes, %d bits unused", @@ -1458,7 +1459,7 @@ OCTET_STRING_print_utf8(asn_TYPE_descriptor_t *td, const void *sptr, void OCTET_STRING_free(asn_TYPE_descriptor_t *td, void *sptr, int contents_only) { OCTET_STRING_t *st = (OCTET_STRING_t *)sptr; - asn_OCTET_STRING_specifics_t *specs = td->specifics + asn_OCTET_STRING_specifics_t *specs = td && td->specifics ? (asn_OCTET_STRING_specifics_t *)td->specifics : &asn_DEF_OCTET_STRING_specs; asn_struct_ctx_t *ctx = (asn_struct_ctx_t *) diff --git a/stglibs/smux.lib/ber_tlv_length.c b/stglibs/smux.lib/ber_tlv_length.c index b87e75e0..32aa5e54 100644 --- a/stglibs/smux.lib/ber_tlv_length.c +++ b/stglibs/smux.lib/ber_tlv_length.c @@ -78,7 +78,6 @@ ssize_t ber_skip_length(asn_codec_ctx_t *opt_codec_ctx, int _is_constructed, const void *ptr, size_t size) { ber_tlv_len_t vlen; /* Length of V in TLV */ - ssize_t tl; /* Length of L in TLV */ ssize_t ll; /* Length of L in TLV */ size_t skip; @@ -112,7 +111,7 @@ ber_skip_length(asn_codec_ctx_t *opt_codec_ctx, ber_tlv_tag_t tag; /* Fetch the tag */ - tl = ber_fetch_tag(ptr, size, &tag); + ssize_t tl = ber_fetch_tag(ptr, size, &tag); if(tl <= 0) return tl; ll = ber_skip_length(opt_codec_ctx, diff --git a/stglibs/smux.lib/constr_CHOICE.c b/stglibs/smux.lib/constr_CHOICE.c index b8d6fa9a..a20a0505 100644 --- a/stglibs/smux.lib/constr_CHOICE.c +++ b/stglibs/smux.lib/constr_CHOICE.c @@ -1020,7 +1020,7 @@ CHOICE_print(asn_TYPE_descriptor_t *td, const void *sptr, int ilevel, void CHOICE_free(asn_TYPE_descriptor_t *td, void *ptr, int contents_only) { - asn_CHOICE_specifics_t *specs = (asn_CHOICE_specifics_t *)td->specifics; + asn_CHOICE_specifics_t *specs = td ? (asn_CHOICE_specifics_t *)td->specifics : NULL; int present; if(!td || !ptr) diff --git a/stglibs/smux.lib/constr_SEQUENCE.c b/stglibs/smux.lib/constr_SEQUENCE.c index b7694343..bc14ca5e 100644 --- a/stglibs/smux.lib/constr_SEQUENCE.c +++ b/stglibs/smux.lib/constr_SEQUENCE.c @@ -648,7 +648,6 @@ SEQUENCE_decode_xer(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, ssize_t ch_size; /* Chunk size */ xer_check_tag_e tcv; /* Tag check value */ asn_TYPE_member_t *elm; - int n; /* * Go inside the inner member of a sequence. @@ -775,6 +774,7 @@ SEQUENCE_decode_xer(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, edx_end = edx + elements[edx].optional + 1; if(edx_end > td->elements_count) edx_end = td->elements_count; + int n; for(n = edx; n < edx_end; n++) { elm = &td->elements[n]; tcv = xer_check_tag(buf_ptr, diff --git a/stglibs/smux.lib/constr_SET_OF.c b/stglibs/smux.lib/constr_SET_OF.c index 09f27db5..0d5efa4f 100644 --- a/stglibs/smux.lib/constr_SET_OF.c +++ b/stglibs/smux.lib/constr_SET_OF.c @@ -904,7 +904,7 @@ SET_OF_decode_uper(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, nelems = uper_get_length(pd, ct ? ct->effective_bits : -1, &repeat); ASN_DEBUG("Got to decode %d elements (eff %d)", - (int)nelems, (int)ct ? ct->effective_bits : -1); + (int)nelems, ct ? ct->effective_bits : -1); if(nelems < 0) _ASN_DECODE_STARVED; } @@ -921,7 +921,7 @@ SET_OF_decode_uper(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, ASN_DEBUG("Failed to add element into %s", td->name); /* Fall through */ - rv.code == RC_FAIL; + rv.code = RC_FAIL; } else { ASN_DEBUG("Failed decoding %s of %s (SET OF)", elm->type->name, td->name);