From c0fbd08dc30d15e888b9204ac6b33471f0df3655 Mon Sep 17 00:00:00 2001 From: Selwin van Dijk Date: Thu, 9 May 2024 13:16:41 +0200 Subject: [PATCH] Update usage() (some typos, removed functions, improve description). memcpy with nullptr is (theoretically) UB, guard some calls. Add move assignment to protobufparser. Fix assignment operator in backupframe. Microoptimization --- arg/usage.cc | 59 ++++++++++++--------- attachmentframe/statics.cc | 2 +- autoversion.h | 2 +- avatarframe/statics.cc | 2 +- backupframe/backupframe.h | 6 +++ common_be.h | 4 ++ cryptbase/cryptbase.h | 10 ++-- cryptbase/getcipherandmac.cc | 2 +- csvreader/csvreader.h | 2 +- csvreader/read.cc | 2 +- csvreader/readrow.cc | 2 +- databaseversionframe/statics.cc | 2 +- endframe/statics.cc | 2 +- fileencryptor/fileencryptor.cc | 2 +- fileencryptor/init.cc | 2 +- framewithattachment/setattachmentdata.cc | 2 +- headerframe/statics.cc | 2 +- keyvalueframe/statics.cc | 2 +- logger/statics.cc | 2 +- memfiledb/statics.cc | 2 +- messagerangeproto/messagerangeproto.h | 2 +- mimetypes/mimetypes.h | 2 +- msgtypes/msgtypes.h | 2 +- protobufparser/protobufparser.h | 43 ++++++++++++--- reactionlist/setauthor.cc | 2 +- sharedprefframe/statics.cc | 2 +- signalbackup/buildsqlstatementframe.cc | 2 +- signalbackup/datetomsecssinceepoch.cc | 2 +- signalbackup/dtsetcolumnnames.cc | 2 +- signalbackup/dtsharedcontactstruct.h | 2 +- signalbackup/fillthreadtablefrommessages.cc | 2 +- signalbackup/getcustomcolor.cc | 2 +- signalbackup/getdtreactions.cc | 2 +- signalbackup/getfreedateformessage.cc | 2 +- signalbackup/getgroupmembers.cc | 2 +- signalbackup/getminmaxusedid.cc | 2 +- signalbackup/getthreadidfromrecipient.cc | 2 +- signalbackup/groupinfo.h | 2 +- signalbackup/handledtgroupchangemessage.cc | 2 +- signalbackup/handledtgroupv1migration.cc | 2 +- signalbackup/handlewamessage.cc | 2 +- signalbackup/htmlicontypes.h | 2 +- signalbackup/importwachat.cc | 2 +- signalbackup/insertreactions.cc | 2 +- signalbackup/makefilenameunique.cc | 2 +- signalbackup/msgrange.h | 2 +- signalbackup/prepareoutputdirectory.cc | 2 +- signalbackup/scramble.cc | 2 +- signalbackup/setfiletimestamp.cc | 2 +- signalbackup/setminimumid.cc | 2 +- signalbackup/statics_html.cc | 2 +- signalbackup/summarize.cc | 2 +- signalbackup/tgbuildbody.cc | 2 +- signalbackup/updategroupmembers.cc | 2 +- signalbackup/updategv1migrationmessage.cc | 2 +- sqlcipherdecryptor/destructor.cc | 2 +- sqlcipherdecryptor/gethmackey.cc | 2 +- sqlcipherdecryptor/getkey.cc | 2 +- sqlitedb/availablewidth.cc | 2 +- sqlitedb/removecolumn.cc | 2 +- sqlitedb/sqlitedb.h | 3 +- sqlitedb/valueasint.cc | 2 +- sqlitedb/valueasstring.cc | 2 +- sqlstatementframe/buildstatement.cc | 2 +- sqlstatementframe/statics.cc | 2 +- stickerframe/statics.cc | 2 +- 66 files changed, 144 insertions(+), 101 deletions(-) diff --git a/arg/usage.cc b/arg/usage.cc index 055732d3..7e3f6fb8 100644 --- a/arg/usage.cc +++ b/arg/usage.cc @@ -25,7 +25,7 @@ void Arg::usage() const Usage: )*" + d_progname + R"*( [] [OPTIONS] must be either a regular file, a backup file as exported by the Signal Android app, or a -directory containing an unpacked backup as createed by this program. In case the input is +directory containing an unpacked backup as created by this program. In case the input is a regular file, a is required. If it is omitted from the command line, a prompt is presented during runtime. Be sure to read the README at https://github.com/bepaald/signalbackup-tools/ for more detailed @@ -53,6 +53,11 @@ changes, you must provide one of the output options. required input for various other options. --listrecipients List all recipients in the database with their `_id'. These id's are required input for various other options. +--setselfid Various options need to know which recipient in the backup is 'self': the + originator of the backup. These functions generally scan the backup to + automatically determine the correct recipient. If this fails, this option + can be used to set the of the backups owner, in the format + it appears in the database, usually `+12345678901'. = OUTPUT OPTIONS = -o, --output Either a file or a directory. When output is a file, this will @@ -64,10 +69,10 @@ changes, you must provide one of the output options. -op, --opassphrase When output is a file, this will be the backups passphrase. May be omitted (in which case the passphrase is used. --onlydb Optional modifier for `--output', when is a directory. - This causes only the SQlite database to be written to disk. + This causes only the SQLite database to be written to disk. --dumpmedia Save all media attachments to DIRECTORY. An attempt is made to give each attachment a correct name and timestamp as well as to - place the attachments in subfolders for each conversation. + place the attachments in sub-folders for each conversation. --limittothreads Optional modifier for `--dumpmedia'. Only save the attachments from the listed threads. List format same as `--croptothreads' --limittothreadsbyname Optional modifier for `--dumpmedia'. Only save the attachments @@ -76,7 +81,7 @@ changes, you must provide one of the output options. --limittodates Optional modifier for `--dumpmedia'. Only export messages within the ranges defined by LIST_OF_DATES. List format is the same as `--croptodates'. - --excludestickers Optional modifier for `--dumpmedia'. Exlcude stickers from the + --excludestickers Optional modifier for `--dumpmedia'. Exclude stickers from the media dump. --dumpavatars Save all avatars to DIRECTORY. --limitcontacts Optional modifier for `--dumpavatars'. Only the avatars of @@ -84,7 +89,7 @@ changes, you must provide one of the output options. 2(,...)", where each name is exactly as it appears in Signal's conversation overview or from this program's `--listrecipients' output. ---exportxml Export the messages from the internal sms table to xml file FILE.)*" +--exportxml Export the messages from the internal sms table to XML file FILE.)*" // --includemms // --includeattachmentdata // --setselfid @@ -115,9 +120,9 @@ R"*( option to output in a light theme instead. --themeswitching Optional modifier for `--exporthtml'. Adds a button to the HTML to switch the theme between light and dark. This adds a bit of - javascript to the page, and sets a cookie when switching. + JavaScript to the page, and sets a cookie when switching. --searchpage Optional modifier for `--exporthtml'. Generates a page from where - conversations can be searched. This adds javascript to the page. + conversations can be searched. This adds JavaScript to the page. Also, a search index is generated to facilitate searching. --includecalllog Optional modifier for `--exporthtml'. Generate a call log-page. --stickerpacks Optional modifier for `--exporthtml'. Generate an overview of @@ -193,8 +198,8 @@ R"*( SIZE bytes. --onlytype Optional modifier for `--deleteattachments' and `--replaceattachments'. Delete attachments only if matching mime - type FILETYPE. The type is need not be complete (ie. `video/m' - will match both `video/mp4' and `video/mpeg' + type FILETYPE. The FILETYPE does not need to be complete + (i.e. `video/m' will match both `video/mp4' and `video/mpeg' --appendbody Optional modifier for `--deleteattachments' and `--replaceattachments'. For each message whose attachment is deleted/replaced, append STRING to the message body. @@ -211,23 +216,24 @@ expected to be very useful to other people. Most of these functions are poorly t possibly outdated. Some will probably eventually be renamed and more thoroughly documented others will be removed. --showdbinfo Prints a list of all tables and columns in the backups - Sqlite database. + SQLite database. --scramble Poorly censors backups, replacing all characters with 'x'. Useful to make screenshots. --scanmissingattachments If you see "warning attachment data not found" messages, feel free to use this option and provide the output to the - developer. ---hiperfall Switch sender and recipient. See - https://github.com/bepaald/signalbackup-tools/issues/44 - --setselfid Optional modifier for `--hiperfall' and `--importwachat' ---importwachat Import whatsapp data. See - https://github.com/bepaald/signalbackup-tools/issues/19 - --setwatimefmt Required modifier for `--importwachat'. ---dumpdesktopdb Decrypts the Signal Desktop database and saves it to the - file `desktop.db'. PATH is the base path of Signal - Desktop's data (eg `~/.config/Signal' on Linux. The program - stupidly still needs an and parameter - to actually run. + developer.)*"; +// --hiperfall Switch sender and recipient. See +// https://github.com/bepaald/signalbackup-tools/issues/44 +// --setselfid Optional modifier for `--hiperfall' and `--importwachat' +// --importwachat Import whatsapp data. See +// https://github.com/bepaald/signalbackup-tools/issues/19 +// --setwatimefmt Required modifier for `--importwachat'. +// --dumpdesktopdb Decrypts the Signal Desktop database and saves it to the +// file `desktop.db'. PATH is the base path of Signal +// Desktop's data (eg `~/.config/Signal' on Linux. The program +// stupidly still needs an and parameter +// to actually run. +std::cout << R"*( --assumebadframesizeonbadmac Used to fix a specific (long fixed) bug in Signal. See https://github.com/signalapp/Signal-Android/issues/9154 --editattachmentsize Modifier for `--assumebadframesizeonbadmac' @@ -259,10 +265,11 @@ be removed. // always be wanted if the NEWNUMBER was already added to the // group. std::cout << R"*( ---mergegroups Merge all messages from OLD_GROUP into NEW_GROUP. ---sleepyh34d Try to import messages from a truncated backup file into a - complete one. See - https://github.com/bepaald/signalbackup-tools/issues/32 +--mergegroups Merge all messages from OLD_GROUP into NEW_GROUP.)*"; +//--sleepyh34d Try to import messages from a truncated backup file into a +// complete one. See +// https://github.com/bepaald/signalbackup-tools/issues/32 +std::cout << R"*( --hhenkel See https://github.com/bepaald/signalbackup-tools/issues/17 )*"; } diff --git a/attachmentframe/statics.cc b/attachmentframe/statics.cc index 7afa30d2..2db8bb13 100644 --- a/attachmentframe/statics.cc +++ b/attachmentframe/statics.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2019-2023 Selwin van Dijk + Copyright (C) 2019-2024 Selwin van Dijk This file is part of signalbackup-tools. diff --git a/autoversion.h b/autoversion.h index 1dbbf2c1..87ef4653 100644 --- a/autoversion.h +++ b/autoversion.h @@ -20,6 +20,6 @@ #ifndef VERSION_H_ #define VERSION_H_ -#define VERSIONDATE "20240507.153601" +#define VERSIONDATE "20240509.131635" #endif diff --git a/avatarframe/statics.cc b/avatarframe/statics.cc index b9461efe..c0161138 100644 --- a/avatarframe/statics.cc +++ b/avatarframe/statics.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2019-2023 Selwin van Dijk + Copyright (C) 2019-2024 Selwin van Dijk This file is part of signalbackup-tools. diff --git a/backupframe/backupframe.h b/backupframe/backupframe.h index 713324cc..c1c8f03d 100644 --- a/backupframe/backupframe.h +++ b/backupframe/backupframe.h @@ -197,6 +197,12 @@ inline BackupFrame &BackupFrame::operator=(BackupFrame const &other) { if (this != &other) { + // properly delete any data this is holding + for (uint i = 0; i < d_framedata.size(); ++i) + if (std::get<1>(d_framedata[i])) + delete[] std::get<1>(d_framedata[i]); + d_framedata.clear(); + d_ok = other.d_ok; d_count = other.d_count; d_constructedsize = other.d_constructedsize; diff --git a/common_be.h b/common_be.h index 70d300ce..307674e6 100644 --- a/common_be.h +++ b/common_be.h @@ -32,6 +32,10 @@ #include #include #include +#if __cpp_lib_byteswap >= 202110L +#include +#endif + // #if defined(_WIN32) || defined(__MINGW64__) // #include diff --git a/cryptbase/cryptbase.h b/cryptbase/cryptbase.h index 04ef650e..f8440cf5 100644 --- a/cryptbase/cryptbase.h +++ b/cryptbase/cryptbase.h @@ -260,12 +260,10 @@ inline void CryptBase::uintToFourBytes(unsigned char *bytes, uint32_t val) const inline uint32_t CryptBase::fourBytesToUint(unsigned char const *b) const { - uint32_t res = 0; - res |= static_cast(b[3] & 0xFF); - res |= static_cast(b[2] & 0xFF) << 8; - res |= static_cast(b[1] & 0xFF) << 16; - res |= static_cast(b[0] & 0xFF) << 24; - return res; + return static_cast(b[3] & 0xFF) | + static_cast(b[2] & 0xFF) << 8 | + static_cast(b[1] & 0xFF) << 16 | + static_cast(b[0] & 0xFF) << 24; } #endif diff --git a/cryptbase/getcipherandmac.cc b/cryptbase/getcipherandmac.cc index 063ee994..fcd8fe03 100644 --- a/cryptbase/getcipherandmac.cc +++ b/cryptbase/getcipherandmac.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2019-2023 Selwin van Dijk + Copyright (C) 2019-2024 Selwin van Dijk This file is part of signalbackup-tools. diff --git a/csvreader/csvreader.h b/csvreader/csvreader.h index 28ab0b08..90311350 100644 --- a/csvreader/csvreader.h +++ b/csvreader/csvreader.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2021-2023 Selwin van Dijk + Copyright (C) 2021-2024 Selwin van Dijk This file is part of signalbackup-tools. diff --git a/csvreader/read.cc b/csvreader/read.cc index bda98aef..900f71d0 100644 --- a/csvreader/read.cc +++ b/csvreader/read.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2021-2023 Selwin van Dijk + Copyright (C) 2021-2024 Selwin van Dijk This file is part of signalbackup-tools. diff --git a/csvreader/readrow.cc b/csvreader/readrow.cc index 3398c7df..e316301b 100644 --- a/csvreader/readrow.cc +++ b/csvreader/readrow.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2021-2023 Selwin van Dijk + Copyright (C) 2021-2024 Selwin van Dijk This file is part of signalbackup-tools. diff --git a/databaseversionframe/statics.cc b/databaseversionframe/statics.cc index 2e01d738..1d971f23 100644 --- a/databaseversionframe/statics.cc +++ b/databaseversionframe/statics.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2019-2023 Selwin van Dijk + Copyright (C) 2019-2024 Selwin van Dijk This file is part of signalbackup-tools. diff --git a/endframe/statics.cc b/endframe/statics.cc index 8d82026f..2ab17d52 100644 --- a/endframe/statics.cc +++ b/endframe/statics.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2019-2023 Selwin van Dijk + Copyright (C) 2019-2024 Selwin van Dijk This file is part of signalbackup-tools. diff --git a/fileencryptor/fileencryptor.cc b/fileencryptor/fileencryptor.cc index 083be687..b228a43f 100644 --- a/fileencryptor/fileencryptor.cc +++ b/fileencryptor/fileencryptor.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2019-2023 Selwin van Dijk + Copyright (C) 2019-2024 Selwin van Dijk This file is part of signalbackup-tools. diff --git a/fileencryptor/init.cc b/fileencryptor/init.cc index 738d12d7..be4ea045 100644 --- a/fileencryptor/init.cc +++ b/fileencryptor/init.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2019-2023 Selwin van Dijk + Copyright (C) 2019-2024 Selwin van Dijk This file is part of signalbackup-tools. diff --git a/framewithattachment/setattachmentdata.cc b/framewithattachment/setattachmentdata.cc index f986073b..9b370be3 100644 --- a/framewithattachment/setattachmentdata.cc +++ b/framewithattachment/setattachmentdata.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2022-2023 Selwin van Dijk + Copyright (C) 2022-2024 Selwin van Dijk This file is part of signalbackup-tools. diff --git a/headerframe/statics.cc b/headerframe/statics.cc index 5dc3a575..fd23c1fa 100644 --- a/headerframe/statics.cc +++ b/headerframe/statics.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2019-2023 Selwin van Dijk + Copyright (C) 2019-2024 Selwin van Dijk This file is part of signalbackup-tools. diff --git a/keyvalueframe/statics.cc b/keyvalueframe/statics.cc index e81224ff..1c601007 100644 --- a/keyvalueframe/statics.cc +++ b/keyvalueframe/statics.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2021-2023 Selwin van Dijk + Copyright (C) 2021-2024 Selwin van Dijk This file is part of signalbackup-tools. diff --git a/logger/statics.cc b/logger/statics.cc index e3403697..5a5c5057 100644 --- a/logger/statics.cc +++ b/logger/statics.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2023 Selwin van Dijk + Copyright (C) 2023-2024 Selwin van Dijk This file is part of signalbackup-tools. diff --git a/memfiledb/statics.cc b/memfiledb/statics.cc index 8cdf3897..afb2d9ee 100644 --- a/memfiledb/statics.cc +++ b/memfiledb/statics.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2019-2023 Selwin van Dijk + Copyright (C) 2019-2024 Selwin van Dijk This file is part of signalbackup-tools. diff --git a/messagerangeproto/messagerangeproto.h b/messagerangeproto/messagerangeproto.h index 693b36df..2d39bed4 100644 --- a/messagerangeproto/messagerangeproto.h +++ b/messagerangeproto/messagerangeproto.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2023 Selwin van Dijk + Copyright (C) 2023-2024 Selwin van Dijk This file is part of signalbackup-tools. diff --git a/mimetypes/mimetypes.h b/mimetypes/mimetypes.h index 9b921a38..824c8e31 100644 --- a/mimetypes/mimetypes.h +++ b/mimetypes/mimetypes.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2021-2023 Selwin van Dijk + Copyright (C) 2021-2024 Selwin van Dijk This file is part of signalbackup-tools. diff --git a/msgtypes/msgtypes.h b/msgtypes/msgtypes.h index baedd93d..eb818790 100644 --- a/msgtypes/msgtypes.h +++ b/msgtypes/msgtypes.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2019-2023 Selwin van Dijk + Copyright (C) 2019-2024 Selwin van Dijk This file is part of signalbackup-tools. diff --git a/protobufparser/protobufparser.h b/protobufparser/protobufparser.h index 827efdc2..559e0c9b 100644 --- a/protobufparser/protobufparser.h +++ b/protobufparser/protobufparser.h @@ -182,12 +182,13 @@ class ProtoBufParser public: inline ProtoBufParser(); - ProtoBufParser(std::string const &base64); + inline ProtoBufParser(std::string const &base64); explicit ProtoBufParser(std::pair, size_t> const &data); explicit ProtoBufParser(unsigned char *data, int64_t size); - ProtoBufParser(ProtoBufParser const &other); + inline ProtoBufParser(ProtoBufParser const &other); inline ProtoBufParser &operator=(ProtoBufParser const &other); - ProtoBufParser(ProtoBufParser &&other); + inline ProtoBufParser(ProtoBufParser &&other); + inline ProtoBufParser &operator=(ProtoBufParser &&other); ~ProtoBufParser(); inline bool operator==(ProtoBufParser const &other) const; inline bool operator!=(ProtoBufParser const &other) const; @@ -281,7 +282,8 @@ inline ProtoBufParser::ProtoBufParser(ProtoBufParser const &other) d_size(0) { d_data = new unsigned char[other.d_size]; - std::memcpy(d_data, other.d_data, other.d_size); + if (other.d_data) + std::memcpy(d_data, other.d_data, other.d_size); d_size = other.d_size; } @@ -290,8 +292,12 @@ inline ProtoBufParser &ProtoBufParser::operator=(ProtoBufParse { if (this != &other) { + if (d_data) + bepaald::destroyPtr(&d_data, &d_size); + d_data = new unsigned char[other.d_size]; - std::memcpy(d_data, other.d_data, other.d_size); + if (other.d_data) + std::memcpy(d_data, other.d_data, other.d_size); d_size = other.d_size; } return *this; @@ -307,6 +313,23 @@ inline ProtoBufParser::ProtoBufParser(ProtoBufParser &&other) other.d_size = 0; } +template +inline ProtoBufParser &ProtoBufParser::operator=(ProtoBufParser &&other) +{ + if (this != &other) + { + if (d_data) + bepaald::destroyPtr(&d_data, &d_size); + + d_data = other.d_data; + d_size = other.d_size; + + other.d_data = nullptr; + other.d_size = 0; + } + return *this; +} + template ProtoBufParser::ProtoBufParser(std::string const &base64) : @@ -333,7 +356,8 @@ ProtoBufParser::ProtoBufParser(unsigned char *data, int64_t size) d_size(0) { d_data = new unsigned char[size]; - std::memcpy(d_data, data, size); + if (data) + std::memcpy(d_data, data, size); d_size = size; } @@ -385,7 +409,8 @@ inline void ProtoBufParser::setData(unsigned char *data, int64_t size) delete[] d_data; d_data = new unsigned char[size]; - std::memcpy(d_data, data, size); + if (data) + std::memcpy(d_data, data, size); d_size = size; } @@ -864,8 +889,10 @@ inline bool ProtoBufParser::addFieldInternal(T const &value) //std::cout << "Adding: " << bepaald::bytesToHexString(mem, size) << std::endl; + // build the new protobuf data, by copying old plus new unsigned char *newdata = new unsigned char[d_size + size]; - std::memcpy(newdata, d_data, d_size); + if (d_data) // when creating a new ProtoBuf from nothing, d_data starts empty, which is UB for memcpy + std::memcpy(newdata, d_data, d_size); std::memcpy(newdata + d_size, mem, size); delete[] mem; diff --git a/reactionlist/setauthor.cc b/reactionlist/setauthor.cc index 3358e62c..278cbb15 100644 --- a/reactionlist/setauthor.cc +++ b/reactionlist/setauthor.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2020-2023 Selwin van Dijk + Copyright (C) 2020-2024 Selwin van Dijk This file is part of signalbackup-tools. diff --git a/sharedprefframe/statics.cc b/sharedprefframe/statics.cc index 25d8ca36..26b7c429 100644 --- a/sharedprefframe/statics.cc +++ b/sharedprefframe/statics.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2019-2023 Selwin van Dijk + Copyright (C) 2019-2024 Selwin van Dijk This file is part of signalbackup-tools. diff --git a/signalbackup/buildsqlstatementframe.cc b/signalbackup/buildsqlstatementframe.cc index 46edbbfe..1ee30f68 100644 --- a/signalbackup/buildsqlstatementframe.cc +++ b/signalbackup/buildsqlstatementframe.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2019-2023 Selwin van Dijk + Copyright (C) 2019-2024 Selwin van Dijk This file is part of signalbackup-tools. diff --git a/signalbackup/datetomsecssinceepoch.cc b/signalbackup/datetomsecssinceepoch.cc index ff216316..15326aae 100644 --- a/signalbackup/datetomsecssinceepoch.cc +++ b/signalbackup/datetomsecssinceepoch.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2019-2023 Selwin van Dijk + Copyright (C) 2019-2024 Selwin van Dijk This file is part of signalbackup-tools. diff --git a/signalbackup/dtsetcolumnnames.cc b/signalbackup/dtsetcolumnnames.cc index c8b9ef15..c277ded8 100644 --- a/signalbackup/dtsetcolumnnames.cc +++ b/signalbackup/dtsetcolumnnames.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2023 Selwin van Dijk + Copyright (C) 2023-2024 Selwin van Dijk This file is part of signalbackup-tools. diff --git a/signalbackup/dtsharedcontactstruct.h b/signalbackup/dtsharedcontactstruct.h index ab9bc70c..5c159680 100644 --- a/signalbackup/dtsharedcontactstruct.h +++ b/signalbackup/dtsharedcontactstruct.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2023 Selwin van Dijk + Copyright (C) 2023-2024 Selwin van Dijk This file is part of signalbackup-tools. diff --git a/signalbackup/fillthreadtablefrommessages.cc b/signalbackup/fillthreadtablefrommessages.cc index c51b9f7f..9d074a51 100644 --- a/signalbackup/fillthreadtablefrommessages.cc +++ b/signalbackup/fillthreadtablefrommessages.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2019-2023 Selwin van Dijk + Copyright (C) 2019-2024 Selwin van Dijk This file is part of signalbackup-tools. diff --git a/signalbackup/getcustomcolor.cc b/signalbackup/getcustomcolor.cc index c9085ee6..fde8cd7e 100644 --- a/signalbackup/getcustomcolor.cc +++ b/signalbackup/getcustomcolor.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2023 Selwin van Dijk + Copyright (C) 2023-2024 Selwin van Dijk This file is part of signalbackup-tools. diff --git a/signalbackup/getdtreactions.cc b/signalbackup/getdtreactions.cc index 70c0782d..34d18d73 100644 --- a/signalbackup/getdtreactions.cc +++ b/signalbackup/getdtreactions.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2022-2023 Selwin van Dijk + Copyright (C) 2022-2024 Selwin van Dijk This file is part of signalbackup-tools. diff --git a/signalbackup/getfreedateformessage.cc b/signalbackup/getfreedateformessage.cc index 7a68b62e..ccb2f578 100644 --- a/signalbackup/getfreedateformessage.cc +++ b/signalbackup/getfreedateformessage.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2023 Selwin van Dijk + Copyright (C) 2023-2024 Selwin van Dijk This file is part of signalbackup-tools. diff --git a/signalbackup/getgroupmembers.cc b/signalbackup/getgroupmembers.cc index b285fa92..9b590c64 100644 --- a/signalbackup/getgroupmembers.cc +++ b/signalbackup/getgroupmembers.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2022-2023 Selwin van Dijk + Copyright (C) 2022-2024 Selwin van Dijk This file is part of signalbackup-tools. diff --git a/signalbackup/getminmaxusedid.cc b/signalbackup/getminmaxusedid.cc index 37e8961a..865f8675 100644 --- a/signalbackup/getminmaxusedid.cc +++ b/signalbackup/getminmaxusedid.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2019-2023 Selwin van Dijk + Copyright (C) 2019-2024 Selwin van Dijk This file is part of signalbackup-tools. diff --git a/signalbackup/getthreadidfromrecipient.cc b/signalbackup/getthreadidfromrecipient.cc index 3e5b5d8e..a76ceb28 100644 --- a/signalbackup/getthreadidfromrecipient.cc +++ b/signalbackup/getthreadidfromrecipient.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2019-2023 Selwin van Dijk + Copyright (C) 2019-2024 Selwin van Dijk This file is part of signalbackup-tools. diff --git a/signalbackup/groupinfo.h b/signalbackup/groupinfo.h index fc4067df..fd396b97 100644 --- a/signalbackup/groupinfo.h +++ b/signalbackup/groupinfo.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2023 Selwin van Dijk + Copyright (C) 2023-2024 Selwin van Dijk This file is part of signalbackup-tools. diff --git a/signalbackup/handledtgroupchangemessage.cc b/signalbackup/handledtgroupchangemessage.cc index 40b1955a..9f31586f 100644 --- a/signalbackup/handledtgroupchangemessage.cc +++ b/signalbackup/handledtgroupchangemessage.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2022-2023 Selwin van Dijk + Copyright (C) 2022-2024 Selwin van Dijk This file is part of signalbackup-tools. diff --git a/signalbackup/handledtgroupv1migration.cc b/signalbackup/handledtgroupv1migration.cc index d13a0232..16f4bdf5 100644 --- a/signalbackup/handledtgroupv1migration.cc +++ b/signalbackup/handledtgroupv1migration.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2023 Selwin van Dijk + Copyright (C) 2023-2024 Selwin van Dijk This file is part of signalbackup-tools. diff --git a/signalbackup/handlewamessage.cc b/signalbackup/handlewamessage.cc index 79435a74..7e1a49ef 100644 --- a/signalbackup/handlewamessage.cc +++ b/signalbackup/handlewamessage.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2021-2023 Selwin van Dijk + Copyright (C) 2021-2024 Selwin van Dijk This file is part of signalbackup-tools. diff --git a/signalbackup/htmlicontypes.h b/signalbackup/htmlicontypes.h index f2b3492a..12844295 100644 --- a/signalbackup/htmlicontypes.h +++ b/signalbackup/htmlicontypes.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2023 Selwin van Dijk + Copyright (C) 2023-2024 Selwin van Dijk This file is part of signalbackup-tools. diff --git a/signalbackup/importwachat.cc b/signalbackup/importwachat.cc index 9990d45f..4b5aba2e 100644 --- a/signalbackup/importwachat.cc +++ b/signalbackup/importwachat.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2021-2023 Selwin van Dijk + Copyright (C) 2021-2024 Selwin van Dijk This file is part of signalbackup-tools. diff --git a/signalbackup/insertreactions.cc b/signalbackup/insertreactions.cc index 93b685c5..76a48f58 100644 --- a/signalbackup/insertreactions.cc +++ b/signalbackup/insertreactions.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2022-2023 Selwin van Dijk + Copyright (C) 2022-2024 Selwin van Dijk This file is part of signalbackup-tools. diff --git a/signalbackup/makefilenameunique.cc b/signalbackup/makefilenameunique.cc index 5479c4ff..0fe6dc25 100644 --- a/signalbackup/makefilenameunique.cc +++ b/signalbackup/makefilenameunique.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2023 Selwin van Dijk + Copyright (C) 2023-2024 Selwin van Dijk This file is part of signalbackup-tools. diff --git a/signalbackup/msgrange.h b/signalbackup/msgrange.h index 91edbe7e..85848904 100644 --- a/signalbackup/msgrange.h +++ b/signalbackup/msgrange.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2023 Selwin van Dijk + Copyright (C) 2023-2024 Selwin van Dijk This file is part of signalbackup-tools. diff --git a/signalbackup/prepareoutputdirectory.cc b/signalbackup/prepareoutputdirectory.cc index 1fff61e4..45a8acb0 100644 --- a/signalbackup/prepareoutputdirectory.cc +++ b/signalbackup/prepareoutputdirectory.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2023 Selwin van Dijk + Copyright (C) 2023-2024 Selwin van Dijk This file is part of signalbackup-tools. diff --git a/signalbackup/scramble.cc b/signalbackup/scramble.cc index 3196d093..fcad897c 100644 --- a/signalbackup/scramble.cc +++ b/signalbackup/scramble.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2022-2023 Selwin van Dijk + Copyright (C) 2022-2024 Selwin van Dijk This file is part of signalbackup-tools. diff --git a/signalbackup/setfiletimestamp.cc b/signalbackup/setfiletimestamp.cc index 23bf2aad..49453b8a 100644 --- a/signalbackup/setfiletimestamp.cc +++ b/signalbackup/setfiletimestamp.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2021-2023 Selwin van Dijk + Copyright (C) 2021-2024 Selwin van Dijk This file is part of signalbackup-tools. diff --git a/signalbackup/setminimumid.cc b/signalbackup/setminimumid.cc index 9b683fca..6f9eecaf 100644 --- a/signalbackup/setminimumid.cc +++ b/signalbackup/setminimumid.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2019-2023 Selwin van Dijk + Copyright (C) 2019-2024 Selwin van Dijk This file is part of signalbackup-tools. diff --git a/signalbackup/statics_html.cc b/signalbackup/statics_html.cc index 275c75f9..1f830a3e 100644 --- a/signalbackup/statics_html.cc +++ b/signalbackup/statics_html.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2023 Selwin van Dijk + Copyright (C) 2023-2024 Selwin van Dijk This file is part of signalbackup-tools. diff --git a/signalbackup/summarize.cc b/signalbackup/summarize.cc index c30baa9f..6a5bfc18 100644 --- a/signalbackup/summarize.cc +++ b/signalbackup/summarize.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2021-2023 Selwin van Dijk + Copyright (C) 2021-2024 Selwin van Dijk This file is part of signalbackup-tools. diff --git a/signalbackup/tgbuildbody.cc b/signalbackup/tgbuildbody.cc index 22f0a5ea..bc443971 100644 --- a/signalbackup/tgbuildbody.cc +++ b/signalbackup/tgbuildbody.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2023 Selwin van Dijk + Copyright (C) 2023-2024 Selwin van Dijk This file is part of signalbackup-tools. diff --git a/signalbackup/updategroupmembers.cc b/signalbackup/updategroupmembers.cc index f8104c1d..f847a8ce 100644 --- a/signalbackup/updategroupmembers.cc +++ b/signalbackup/updategroupmembers.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2022-2023 Selwin van Dijk + Copyright (C) 2022-2024 Selwin van Dijk This file is part of signalbackup-tools. diff --git a/signalbackup/updategv1migrationmessage.cc b/signalbackup/updategv1migrationmessage.cc index fa692de6..1ad7b409 100644 --- a/signalbackup/updategv1migrationmessage.cc +++ b/signalbackup/updategv1migrationmessage.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2022-2023 Selwin van Dijk + Copyright (C) 2022-2024 Selwin van Dijk This file is part of signalbackup-tools. diff --git a/sqlcipherdecryptor/destructor.cc b/sqlcipherdecryptor/destructor.cc index b50640e2..03e094b3 100644 --- a/sqlcipherdecryptor/destructor.cc +++ b/sqlcipherdecryptor/destructor.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2019-2023 Selwin van Dijk + Copyright (C) 2019-2024 Selwin van Dijk This file is part of signalbackup-tools. diff --git a/sqlcipherdecryptor/gethmackey.cc b/sqlcipherdecryptor/gethmackey.cc index d32a67ea..38923fb3 100644 --- a/sqlcipherdecryptor/gethmackey.cc +++ b/sqlcipherdecryptor/gethmackey.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2019-2023 Selwin van Dijk + Copyright (C) 2019-2024 Selwin van Dijk This file is part of signalbackup-tools. diff --git a/sqlcipherdecryptor/getkey.cc b/sqlcipherdecryptor/getkey.cc index da3ec047..5ee14d04 100644 --- a/sqlcipherdecryptor/getkey.cc +++ b/sqlcipherdecryptor/getkey.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2019-2023 Selwin van Dijk + Copyright (C) 2019-2024 Selwin van Dijk This file is part of signalbackup-tools. diff --git a/sqlitedb/availablewidth.cc b/sqlitedb/availablewidth.cc index fa828180..e8f33eab 100644 --- a/sqlitedb/availablewidth.cc +++ b/sqlitedb/availablewidth.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2019-2023 Selwin van Dijk + Copyright (C) 2019-2024 Selwin van Dijk This file is part of signalbackup-tools. diff --git a/sqlitedb/removecolumn.cc b/sqlitedb/removecolumn.cc index 1a785ce7..f74eefba 100644 --- a/sqlitedb/removecolumn.cc +++ b/sqlitedb/removecolumn.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2020-2023 Selwin van Dijk + Copyright (C) 2020-2024 Selwin van Dijk This file is part of signalbackup-tools. diff --git a/sqlitedb/sqlitedb.h b/sqlitedb/sqlitedb.h index 67883603..17fb83b5 100644 --- a/sqlitedb/sqlitedb.h +++ b/sqlitedb/sqlitedb.h @@ -525,7 +525,8 @@ inline bool SqliteDB::exec(std::string const &q, std::vector const &pa { size_t blobsize = sqlite3_column_bytes(d_stmt, c); std::shared_ptr blob(new unsigned char[blobsize]); - std::memcpy(blob.get(), reinterpret_cast(sqlite3_column_blob(d_stmt, c)), blobsize); + if (blobsize) // if 0, sqlite3_column_blob() is nullptr, which is UB for memcpy + std::memcpy(blob.get(), reinterpret_cast(sqlite3_column_blob(d_stmt, c)), blobsize); results->emplaceValue(row, std::make_pair(blob, blobsize)); } } diff --git a/sqlitedb/valueasint.cc b/sqlitedb/valueasint.cc index 50732cfd..362dfbc1 100644 --- a/sqlitedb/valueasint.cc +++ b/sqlitedb/valueasint.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2023 Selwin van Dijk + Copyright (C) 2023-2024 Selwin van Dijk This file is part of signalbackup-tools. diff --git a/sqlitedb/valueasstring.cc b/sqlitedb/valueasstring.cc index 68d64fb3..64c094dc 100644 --- a/sqlitedb/valueasstring.cc +++ b/sqlitedb/valueasstring.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2019-2023 Selwin van Dijk + Copyright (C) 2019-2024 Selwin van Dijk This file is part of signalbackup-tools. diff --git a/sqlstatementframe/buildstatement.cc b/sqlstatementframe/buildstatement.cc index c7a95ecb..eeaf9c44 100644 --- a/sqlstatementframe/buildstatement.cc +++ b/sqlstatementframe/buildstatement.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2019-2023 Selwin van Dijk + Copyright (C) 2019-2024 Selwin van Dijk This file is part of signalbackup-tools. diff --git a/sqlstatementframe/statics.cc b/sqlstatementframe/statics.cc index 71091241..1ce62374 100644 --- a/sqlstatementframe/statics.cc +++ b/sqlstatementframe/statics.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2019-2023 Selwin van Dijk + Copyright (C) 2019-2024 Selwin van Dijk This file is part of signalbackup-tools. diff --git a/stickerframe/statics.cc b/stickerframe/statics.cc index 4eaaa3a7..93440278 100644 --- a/stickerframe/statics.cc +++ b/stickerframe/statics.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2019-2023 Selwin van Dijk + Copyright (C) 2019-2024 Selwin van Dijk This file is part of signalbackup-tools.