1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00

Merge branch 'v1.17-dev'

This commit is contained in:
Anthony Bilinski 2020-04-24 18:35:00 -07:00
commit c748b5a8d0
No known key found for this signature in database
GPG Key ID: 2AA8E0DA1B31FB3C
9 changed files with 75 additions and 12 deletions

View File

@ -165,6 +165,7 @@ build_qtox() {
echo '*** BUILDING "MINIMAL" VERSION ***'
cmake -H. -B"$BUILDDIR" \
-DSMILEYS=DISABLED \
-DSTRICT_OPTIONS=ON \
-DSPELL_CHECK=OFF
bdir
@ -173,7 +174,9 @@ build_qtox() {
rm -rf "$BUILDDIR"
echo '*** BUILDING "FULL" VERSION ***'
cmake -H. -B"$BUILDDIR" -DUPDATE_CHECK=ON
cmake -H. -B"$BUILDDIR" \
-DUPDATE_CHECK=ON \
-DSTRICT_OPTIONS=ON
bdir
}

View File

@ -30,6 +30,7 @@ option(SPELL_CHECK "Enable spell cheching support" ON)
option(SVGZ_ICON "Compress the SVG icon of qTox" ON)
option(ASAN "Compile with AddressSanitizer" OFF)
option(DESKTOP_NOTIFICATIONS "Use snorenotify for desktop notifications" OFF)
option(STRICT_OPTIONS "Enable strict compile options, used by CI" OFF)
# process generated files if cmake >= 3.10
if(POLICY CMP0071)
@ -87,7 +88,11 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wstrict-aliasing")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wold-style-cast")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wsign-compare")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wunknown-pragmas")
# Extra-strict compile options that we don't want to subject all users to by default
if (STRICT_OPTIONS)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror")
endif()
# avoid timestamps in binary for reproducible builds, not added until GCC 4.9
include(CheckCXXCompilerFlag)
@ -373,6 +378,7 @@ set(${PROJECT_NAME}_SOURCES
src/model/sessionchatlog.cpp
src/model/chathistory.h
src/model/chathistory.cpp
src/model/toxclientstandards.h
src/net/bootstrapnodeupdater.cpp
src/net/bootstrapnodeupdater.h
src/net/avatarbroadcaster.cpp

View File

@ -107,6 +107,7 @@ cd _build
# need to build with -DDESKTOP_NOTIFICATIONS=True for snorenotify
cmake -DDESKTOP_NOTIFICATIONS=True \
-DUPDATE_CHECK=True \
-DSTRICT_OPTIONS=True \
../
make

View File

@ -120,7 +120,10 @@
{
"name": "qTox",
"buildsystem": "cmake-ninja",
"config-opts": ["-DSVGZ_ICON=OFF"],
"config-opts": [
"-DSVGZ_ICON=OFF",
"-DSTRICT_OPTIONS=ON"
],
"sources": [
{
"type": "dir",
@ -130,4 +133,3 @@
}
]
}

View File

@ -262,7 +262,14 @@ build() {
fcho "Now working in ${PWD}"
fcho "Starting cmake ..."
export CMAKE_PREFIX_PATH=$(brew --prefix qt5)
cmake -H$QTOX_DIR -B. -DUPDATE_CHECK=ON -DSPELL_CHECK=OFF
if [[ $TRAVIS = true ]]
then
STRICT_OPTIONS="ON"
else
STRICT_OPTIONS="OFF"
fi
cmake -H$QTOX_DIR -B. -DUPDATE_CHECK=ON -DSPELL_CHECK=OFF -DSTRICT_OPTIONS="${STRICT_OPTIONS}"
make -j$(sysctl -n hw.ncpu)
}

View File

@ -24,6 +24,7 @@
#include "toxstring.h"
#include "src/persistence/settings.h"
#include "src/model/status.h"
#include "src/model/toxclientstandards.h"
#include <QDebug>
#include <QDir>
#include <QFile>
@ -330,6 +331,13 @@ void CoreFile::onFileReceiveCallback(Tox* tox, uint32_t friendId, uint32_t fileI
emit core->friendAvatarRemoved(core->getFriendPublicKey(friendId));
return;
} else {
if (!ToxClientStandards::IsValidAvatarSize(filesize)) {
qWarning() <<
QString("Received avatar request from %1 with size %2.").arg(friendId).arg(filesize) +
QString(" The max size allowed for avatars is %3. Cancelling transfer.").arg(ToxClientStandards::MaxAvatarSize);
tox_file_control(tox, friendId, fileId, TOX_FILE_CONTROL_CANCEL, nullptr);
return;
}
static_assert(TOX_HASH_LENGTH <= TOX_FILE_ID_LENGTH,
"TOX_HASH_LENGTH > TOX_FILE_ID_LENGTH!");
uint8_t avatarHash[TOX_FILE_ID_LENGTH];

View File

@ -22,6 +22,7 @@
#include "src/nexus.h"
#include "src/persistence/profile.h"
#include "src/persistence/settings.h"
#include "src/model/toxclientstandards.h"
#include <QApplication>
#include <QBuffer>
@ -358,13 +359,11 @@ IProfileInfo::SetAvatarResult ProfileInfo::byteArrayToPng(QByteArray inData, QBy
*/
IProfileInfo::SetAvatarResult ProfileInfo::scalePngToAvatar(QByteArray& avatar)
{
// https://tox.gitbooks.io/tox-client-standard/content/user_identification/avatar.html
constexpr int maxSize = 65535;
// We do a first rescale to 256x256 in case the image was huge, then keep tryng from here
constexpr int scaleSizes[] = {256, 128, 64, 32};
for (auto scaleSize : scaleSizes) {
if (avatar.size() <= maxSize)
if (ToxClientStandards::IsValidAvatarSize(avatar.size()))
break;
QImage image;
image.loadFromData(avatar);
@ -373,7 +372,7 @@ IProfileInfo::SetAvatarResult ProfileInfo::scalePngToAvatar(QByteArray& avatar)
}
// If this happens, you're really doing it on purpose.
if (avatar.size() > maxSize) {
if (!ToxClientStandards::IsValidAvatarSize(avatar.size())) {
return SetAvatarResult::TooLarge;
}
return SetAvatarResult::OK;

View File

@ -0,0 +1,35 @@
/*
Copyright © 2020 by The qTox Project Contributors
This file is part of qTox, a Qt-based graphical interface for Tox.
qTox is libre 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.
qTox 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 qTox. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef TOXCLIENTSTANDARDS_H
#define TOXCLIENTSTANDARDS_H
#include <cstdint>
namespace ToxClientStandards
{
// From TCS 2.2.4, max valid avatar size is 64KiB
constexpr static uint64_t MaxAvatarSize = 64 * 1024;
constexpr bool IsValidAvatarSize(uint64_t fileSize)
{
return fileSize <= MaxAvatarSize;
}
} // ToxClientStandards
#endif // TOXCLIENTSTANDARDS_H

View File

@ -229,9 +229,9 @@ store_apt_cache()
# OpenSSL
OPENSSL_PREFIX_DIR="$DEP_DIR/libopenssl"
OPENSSL_VERSION=1.1.1d
OPENSSL_VERSION=1.1.1f
# hash from https://www.openssl.org/source/
OPENSSL_HASH="1e3a91bc1f9dfce01af26026f856e064eab4c8ee0a8f457b5ae30b40b8b711f2"
OPENSSL_HASH="186c6bfe6ecfba7a5b48c47f8a1673d0f3b0e5ba2e25602dd23b629975da3f35"
OPENSSL_FILENAME="openssl-$OPENSSL_VERSION.tar.gz"
if [ ! -f "$OPENSSL_PREFIX_DIR/done" ]
then
@ -977,6 +977,7 @@ then
-DCMAKE_BUILD_TYPE=Release \
-DSPELL_CHECK=OFF \
-DUPDATE_CHECK=ON \
-DSTRICT_OPTIONS=ON \
..
elif [[ "$BUILD_TYPE" == "debug" ]]
then
@ -984,6 +985,7 @@ then
-DCMAKE_BUILD_TYPE=Debug \
-DSPELL_CHECK=OFF \
-DUPDATE_CHECK=ON \
-DSTRICT_OPTIONS=ON \
..
fi