Just initialize to NULL before going forward.
Fixes:
CID 542426: (#1 of 1): Uninitialized pointer read (UNINIT)
21. uninit_use_in_call: Using uninitialized value script_config.diags when calling operator =
Change-Id: I4ed97e4fbeb371f04f0496565fa03b7b4a302e02
We still have raw pointers in the variant and so we need to deal with
copying the contained objects ourselves.
Change-Id: I0e5f1b56430ffeda9d34ede30ec87cfd45a61662
This doesn't yet do much in terms of memory management as it still uses
pointers for arrays and structs, but it does move management of strings
and blobs into the variant. Further refactoring will bring the full
benefits.
Add specialised == operator to avoid implicit conversions to temporary
AmArg.
Includes white space cleanups.
Change-Id: I1e4bce6b96c2187294044f9f2a30fa7013912139
Move from debian/rules into actual makefile. This is not Debian-specific
and needs to be set for a successful build.
Also it's not a preprocessor option, it's a C++ option.
Change-Id: I19be56f4e319778def5697b1fdbc77a9988ccb9b
Add missing initialisers and fix order.
In some cases the member was actually unused and could just be removed.
Change-Id: I0f0c927eb8271c35dcfd371f225847f62bea2812
Warned-by: Coverity
We are passing here null pointer (so `this->dlg->getCallid()`)
which isn't good.
Just use a default `WARN()` instead.
Fixes:
*** CID 549008: Null pointer dereferences (FORWARD_NULL)
/apps/sbc/CallLeg.cpp: 193 in CallLeg::CallLeg(const CallLeg*, AmSipDialog *, AmSipSubscription *)()
187
188 // enable OA for the purpose of hold request detection
189 if (dlg) {
190 dlg->setOAEnabled(true);
191 dlg->setOAForceSDP(false);
192 }
>>> CID 549008: Null pointer dereferences (FORWARD_NULL)
>>> Passing null pointer "this->dlg->getCallid()" to "c_str", which dereferences it.
[Note: The source code implementation of the function has been overridden by a builtin model.]
193 else ILOG_DLG(L_WARN, "can't enable OA!\n");
194
195 // code below taken from createCalleeSession
196
197 const AmSipDialog* caller_dlg = caller->dlg;
198
Change-Id: If1f62386c9a2d3f6df4a12a2b157802b8a0677fa
These are all instances of an object being put into a container just
before it goes out of scope. Use move semantics to avoid copying.
Change-Id: I9c40a56c4a67df2b8e244d51f068b50ec286f5bf
Warned-by: Coverity
Use a static cast to make sure we use the right type for
std::string::length()
Change-Id: I3b21146ca8898d7e1f3b35c83389d37eadac5ff6
Warned-by: Coverity
Make it more explicit that this is meant to set the flag instead of
doing a comparison with a typo.
Change-Id: I31a1a7f35b9072f157105f6c2acdd2caf9bea09a
Warned-by: Coverity
Otherwise we can end up with:
Program terminated with signal SIGSEGV, Segmentation fault.
104 ./core/AmSession.cpp: No such file or directory.
[Current thread is 1 (Thread 0x7fc7dd677e40 (LWP 176249))]
Change-Id: Ia61de0caa9b1764839c740e62bc3f463da4ed4dc
Introduce `ILOG_SDLG()` call-id logging based on
specific getter provided to the macro func as a param.
This is required for those implementations,
where there is no within-file common dialog id getter.
Change-Id: I90501a0da32c7b8075e181796cf4c7c3f980e81e
Make the way we get call-id when calling ILOG_DLG()
file specific, which allows to define locally
(within a target file) how to get the call-id value.
Change-Id: I4af87edf9d1ea52d9678b3354bc797cf1f5f0b54
A fix-up for 3745ff0778d6a55.
This must fix:
Program terminated with signal SIGSEGV, Segmentation fault.
"*\302\3242R \204\vg\266f9\356\277[\252\336J\205\371\020Ŵ\313ٛ\v\231\214\360\355\243\034g\022\001\n\025")
at ./core/sip/sip_parser_async.cpp:205
205 ./core/sip/sip_parser_async.cpp: No such file or directory.
[Current thread is 1 (Thread 0x7f80c07ea6c0 (LWP 3928994))]
(gdb) bt full
"*\302\3242R \204\vg\266f9\356\277[\252\336J\205\371\020Ŵ\313ٛ\v\231\214\360\355\243\034g\022\001\n\025")
at ./core/sip/sip_parser_async.cpp:205
err = 0
c = @0x7f807c001390: 0x7f807c00140e "*\302\3242R \204\vg\266f9\356\277[\252\336J\205\371\020Ŵ\313ٛ\v\231\214\360\355\243\034g\022\001\n\025"
st = @0x7f807c0013a4: 102
saved_st = @0x7f807c0013a8: 0
hdr = 0x0
Change-Id: Icde152783b9dc5a68dde9d29f96d1d87b36e0671
In some cases it can happen that ::join() is called from multiple
threads at the same time. Checking the ::joinable() flag is not
race-free and so is unreliable to make sure that only one other thread
attempts to join at any given time. Add a mutex and a state variable to
make sure only one thread attempts to join, and make any other threads
wait.
Change-Id: I02fd236a416b035c98642535f1521be4a3a63fd9
Fall through so that the shutdown flag gets set and so that the SIP
control sockets get shut down.
Change-Id: I205db4c7aa72dd9576f42b0d9bc2ec4960fd5415
On shutdown, call shutdown() in the socket, so that a thread blocked in
recv() wakes up and gets a chance to exit cleanly.
Change-Id: I24b1b7c608ec1307019b424becef31e8db02e7bb
Zero is a valid file descriptor. Anything that's not -1 can in fact be a
valid file descriptor.
Make sure `sd` is set to -1 whenever no socket is open.
Add dtor to socket class to close the socket if it's open.
Add a few related formatting fixes as well.
Change-Id: Id9d3ad74b986c82ac6ab698a1e8f1f38e0f92414
Classes that inherit from both AmThread and AmEventHandler must inherit
from AmEventQueue first and from AmThread after. This is needed so that
the AmThread dtor is called first, which will trigger the thread to shut
down, which in turn makes sure nothing is waiting on the AmEventQueue's
condition variable.
Otherwise, if AmEventQueue is destroyed first while the corresponding
thread is still running and waiting on the condition variable, it will
be a deadlock.
With this, sems finally can shut down cleanly without having to be
killed by systemd.
Change-Id: I914455763b517c96561acb0b64fce26f127f44bc
Request a thread shutdown in the dtor in case the thread is still
running. Prevents destruction of std::thread with an active thread.
Change-Id: I51c4a43cf8d6402f4a690add936c95c2f700129d
Use a timed condition waiter instead of waiting forever. This is needed
to be able to react to a requested thread shutdown.
Change-Id: I062b6045d737eb16cab8f052375d81a1988e95e8
Provide a single place for a running thread to check if it ought to shut
down. Use it in AmThreadWatcher.
Change-Id: I206111b34e3c658f0c2ce55627274b463b1e98d5
Use a std::list instead of a std::queue so that we can use iterators,
which allows us to delete elements directly without having to rebuild a
new queue with every loop iteration. This eliminates the n_thread_queue
and the swap.
Eliminate the wait condition _run_cond. This is only woken up when a
thread is added, which we don't care about. We only care when a thread
finishes, and there is no condition for that.
Use a lock guard. With this we can make sure the lock is in a consistent
state in case of an exception. Still catch and report exceptions.
Remove stub methods.
Change-Id: I59903f6a03863e5c106631e3db8706109915c8fb
Use an atomic enum to track state: idle, running, stopping, or stopped.
Use atomic compare and exchange to ensure consistency without requiring
a mutex.
Never detach threads. Always require a join. This makes for an easy and
reliable way to wait for a thread to finish.
Provide a default on_stop so that it can be omitted in child classes.
Change-Id: Id59942638b7f769090ac91c2049b7d934e876ffc
Use a manual lock to make read/write operations
to the `std::map<DSMModule*, void*> mods_hdls` safer.
Change-Id: I45fb46bab603e2817bd98cd99267ed813122e548
Just add the following flags,
which are affecting the usage in our newer functionality:
- ssl
- crypto
Change-Id: Ia3edf1b77316fd64f7f55a5d2600fee730a285b4
Take into account that par2, used to pass N-th
amount of parameters, is properly exploded into
separate string objects having no spaces and
escaped double-quotes. Otherwise resolution fails.
Fixes:
[runactions, DSMStateEngine.cpp:334] DEBUG: executing 'utils.playRingTone(0, $config.rbt_on, $config.rbt_off, $config.rbt_f, $config.rbt_f2)'
[str2int, AmUtils.cpp:353] DEBUG: str2i: unexpected char 0x24 in $config.rbt_off
[execute, ModUtils.cpp:554] WARNING: could not decipher ringtone parameter 1: ' $config.rbt_off', using default
[str2int, AmUtils.cpp:353] DEBUG: str2i: unexpected char 0x24 in $config.rbt_f
[execute, ModUtils.cpp:554] WARNING: could not decipher ringtone parameter 2: ' $config.rbt_f', using default
[str2int, AmUtils.cpp:353] DEBUG: str2i: unexpected char 0x24 in $config.rbt_f2
[execute, ModUtils.cpp:554] WARNING: could not decipher ringtone parameter 3: ' $config.rbt_f2', using default
[execute, ModUtils.cpp:560] DEBUG: Playing ringtone length 0, on 1000, off 4000, f 440, f2 480
Change-Id: Ifed353478464d8071b5ca64959a7d4de6c877c8f
New functions introduced for DSM API (mod_utils):
- encryptCodeAes128CBC()
- decryptCodeAes128CBC()
Will be used by the voucher DSM application to encrypt/decrypt
the code given by a subscriber when filling up the balance.
OpenSSL AES128 CBC is used as an algorithm.
(with default AES key size 16 bytes)
Required things to let it be working:
- base64 encoding/decoding (of binary raw data)
- padding based on default AES key size (16)
Change-Id: I4b47f49ebf4b61157c3a4631cd8302565c660bc3