Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Open sidebar
savoirfairelinux
jami-daemon
Commits
ec08da89
Commit
ec08da89
authored
Apr 12, 2012
by
Tristan Matthews
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
* #9782: fix ARRAYSIZE check
parent
44729d3e
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
50 additions
and
14 deletions
+50
-14
daemon/src/Makefile.am
daemon/src/Makefile.am
+2
-1
daemon/src/array_size.h
daemon/src/array_size.h
+39
-0
daemon/src/audio/audiortp/audio_srtp_session.cpp
daemon/src/audio/audiortp/audio_srtp_session.cpp
+4
-4
daemon/src/audio/audiortp/audio_srtp_session.h
daemon/src/audio/audiortp/audio_srtp_session.h
+4
-4
daemon/test/delaydetectiontest.cpp
daemon/test/delaydetectiontest.cpp
+1
-0
daemon/test/test_utils.h
daemon/test/test_utils.h
+0
-5
No files found.
daemon/src/Makefile.am
View file @
ec08da89
...
...
@@ -51,7 +51,8 @@ noinst_HEADERS = \
noncopyable.h
\
cc_thread.h
\
cc_config.h
\
sfl_types.h
sfl_types.h
\
array_size.h
libsflphone_la_LIBADD
=
\
$(top_builddir)
/libs/iax2/libiax2.la
\
...
...
daemon/src/array_size.h
0 → 100644
View file @
ec08da89
/*
* Copyright (C) 2004-2012 Savoir-Faire Linux Inc.
* Author: Tristan Matthews <tristan.matthews@savoirfairelinux.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
* Additional permission under GNU GPL version 3 section 7:
*
* If you modify this program, or any covered work, by linking or
* combining it with the OpenSSL project's OpenSSL library (or a
* modified version of that library), containing parts covered by the
* terms of the OpenSSL or SSLeay licenses, Savoir-Faire Linux Inc.
* grants you additional permission to convey the resulting work.
* Corresponding Source for a non-source form of such a combination
* shall include the source code for the parts of OpenSSL used as well
* as that of the covered work.
*/
#ifndef ARRAY_SIZE_H_
#define ARRAY_SIZE_H_
// Returns the number of elements in a, calculated at compile-time
#define ARRAYSIZE(a) \
((sizeof(a) / sizeof(*(a))) / \
static_cast<size_t>(!(sizeof(a) % sizeof(*(a)))))
#endif // ARRAY_SIZE_H_
daemon/src/audio/audiortp/audio_srtp_session.cpp
View file @
ec08da89
...
...
@@ -29,6 +29,7 @@
*/
#include "audio_srtp_session.h"
#include "logger.h"
#include "array_size.h"
#include <openssl/sha.h>
#include <openssl/hmac.h>
...
...
@@ -103,12 +104,9 @@ namespace {
std
::
vector
<
unsigned
char
>
random_key
(
length
);
// Generate ryptographically strong pseudo-random bytes
int
err
;
if
((
err
=
RAND_bytes
(
&
(
*
random_key
.
begin
()),
length
))
!=
1
)
if
(
RAND_bytes
(
&
(
*
random_key
.
begin
()),
length
)
!=
1
)
DEBUG
(
"Error occured while generating cryptographically strong pseudo-random key"
);
assert
((
sizeof
dest
/
sizeof
dest
[
0
])
<=
length
);
memcpy
(
dest
,
&
(
*
random_key
.
begin
()),
length
);
}
}
...
...
@@ -211,6 +209,7 @@ void AudioSrtpSession::initializeLocalMasterKey()
DEBUG
(
"AudioSrtp: Init local master key"
);
// @TODO key may have different length depending on cipher suite
localMasterKeyLength_
=
sfl
::
CryptoSuites
[
localCryptoSuite_
].
masterKeyLength
/
8
;
assert
(
ARRAYSIZE
(
localMasterKey_
)
>=
localMasterKeyLength_
);
DEBUG
(
"AudioSrtp: Local master key length %d"
,
localMasterKeyLength_
);
buffer_fill
(
localMasterKey_
,
localMasterKeyLength_
);
}
...
...
@@ -219,6 +218,7 @@ void AudioSrtpSession::initializeLocalMasterSalt()
{
// @TODO key may have different length depending on cipher suite
localMasterSaltLength_
=
sfl
::
CryptoSuites
[
localCryptoSuite_
].
masterSaltLength
/
8
;
assert
(
ARRAYSIZE
(
localMasterSalt_
)
>=
localMasterSaltLength_
);
DEBUG
(
"AudioSrtp: Local master salt length %d"
,
localMasterSaltLength_
);
buffer_fill
(
localMasterSalt_
,
localMasterSaltLength_
);
}
...
...
daemon/src/audio/audiortp/audio_srtp_session.h
View file @
ec08da89
...
...
@@ -153,22 +153,22 @@ class AudioSrtpSession : public AudioSymmetricRtpSession {
uint8
localMasterKey_
[
16
];
/** local master key length in byte */
in
t
localMasterKeyLength_
;
size_
t
localMasterKeyLength_
;
uint8
localMasterSalt_
[
14
];
/** local master salt length in byte */
in
t
localMasterSaltLength_
;
size_
t
localMasterSaltLength_
;
uint8
remoteMasterKey_
[
16
];
/** remote master key length in byte */
in
t
remoteMasterKeyLength_
;
size_
t
remoteMasterKeyLength_
;
uint8
remoteMasterSalt_
[
14
];
/** remote master salt length in byte */
in
t
remoteMasterSaltLength_
;
size_
t
remoteMasterSaltLength_
;
/** Used to make sure remote crypto context not initialized wice. */
bool
remoteOfferIsSet_
;
...
...
daemon/test/delaydetectiontest.cpp
View file @
ec08da89
...
...
@@ -31,6 +31,7 @@
#include "delaydetectiontest.h"
#include <cstring>
#include "array_size.h"
void
DelayDetectionTest
::
testCrossCorrelation
()
{
...
...
daemon/test/test_utils.h
View file @
ec08da89
...
...
@@ -34,9 +34,4 @@
#define TITLE() DEBUG("-------------------- %s --------------------\n", \
__PRETTY_FUNCTION__)
// Returns the number of elements in a, calculated at compile-time
#define ARRAYSIZE(a) \
((sizeof(a) / sizeof(*(a))) / \
static_cast<size_t>(!(sizeof(a) % sizeof(*(a)))))
#endif // TEST_UTILS_H_
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment