From d744e8be15b1162b0a2f4205da48478cce3f2207 Mon Sep 17 00:00:00 2001 From: Robert Adam Date: Sun, 13 Nov 2022 18:46:15 +0100 Subject: [PATCH] REFAC: Get rid of non-standard variable-size arrays Using VSAs depends on compiler-specific, non-standard extensions and we should generally avoid that. The changed code could probably be made quite a bit more efficient by keeping the vector(s) around between function calls, but this kind of optimization is ought to be performed at some point in the future. --- src/mumble/ALSAAudio.cpp | 27 ++++++++++--------- src/mumble/AudioInput.cpp | 6 +++-- src/mumble/AudioOutput.cpp | 11 +++++--- src/mumble/AudioOutputSample.cpp | 5 ++-- src/mumble/AudioStats.cpp | 28 +++++++++++-------- src/mumble/PulseAudio.cpp | 14 +++++----- src/mumble/ServerHandler.cpp | 7 ++--- src/mumble/main.cpp | 3 ++- src/mumble/os_win.cpp | 3 ++- src/murmur/Server.cpp | 19 ++++++++----- src/tests/TestCrypt/TestCrypt.cpp | 45 ++++++++++++++++++------------- 11 files changed, 99 insertions(+), 69 deletions(-) diff --git a/src/mumble/ALSAAudio.cpp b/src/mumble/ALSAAudio.cpp index 3d512f10fc2..2f4f07190ce 100644 --- a/src/mumble/ALSAAudio.cpp +++ b/src/mumble/ALSAAudio.cpp @@ -367,7 +367,8 @@ void ALSAAudioInput::run() { eMicFormat = SampleShort; initializeMixer(); - char inbuff[wantPeriod * iChannels * sizeof(short)]; + std::vector< char > inbuff; + inbuff.resize(wantPeriod * iChannels * sizeof(short)); qml.unlock(); @@ -378,7 +379,7 @@ void ALSAAudioInput::run() { snd_pcm_status_dump(status, log); snd_pcm_status_free(status); #endif - readblapp = snd_pcm_readi(capture_handle, inbuff, static_cast< int >(wantPeriod)); + readblapp = snd_pcm_readi(capture_handle, inbuff.data(), static_cast< int >(wantPeriod)); if (readblapp == -ESTRPIPE) { qWarning("ALSAAudioInput: PCM suspended, trying to resume"); while (bRunning && snd_pcm_resume(capture_handle) == -EAGAIN) @@ -392,7 +393,7 @@ void ALSAAudioInput::run() { err = snd_pcm_prepare(capture_handle); qWarning("ALSAAudioInput: %s: %s", snd_strerror(static_cast< int >(readblapp)), snd_strerror(err)); } else if (wantPeriod == static_cast< unsigned int >(readblapp)) { - addMic(inbuff, static_cast< int >(readblapp)); + addMic(inbuff.data(), static_cast< int >(readblapp)); } } @@ -483,8 +484,10 @@ void ALSAAudioOutput::run() { const unsigned int buffsize = static_cast< unsigned int >(period_size * iChannels); - float zerobuff[buffsize]; - float outbuff[buffsize]; + std::vector< float > zerobuff; + zerobuff.resize(buffsize); + std::vector< float > outbuff; + outbuff.resize(buffsize); for (unsigned int i = 0; i < buffsize; i++) zerobuff[i] = 0; @@ -492,7 +495,7 @@ void ALSAAudioOutput::run() { // Fill buffer if (bOk && pcm_handle) for (unsigned int i = 0; i < buffer_size / period_size; i++) - snd_pcm_writei(pcm_handle, zerobuff, period_size); + snd_pcm_writei(pcm_handle, zerobuff.data(), period_size); if (!bOk) { Global::get().mw->msgBox( @@ -533,10 +536,10 @@ void ALSAAudioOutput::run() { snd_pcm_sframes_t avail{}; ALSA_ERRCHECK(avail = snd_pcm_avail_update(pcm_handle)); while (avail >= static_cast< int >(period_size)) { - stillRun = mix(outbuff, static_cast< int >(period_size)); + stillRun = mix(outbuff.data(), static_cast< int >(period_size)); if (stillRun) { snd_pcm_sframes_t w = 0; - ALSA_ERRCHECK(w = snd_pcm_writei(pcm_handle, outbuff, period_size)); + ALSA_ERRCHECK(w = snd_pcm_writei(pcm_handle, outbuff.data(), period_size)); if (w < 0) { avail = w; break; @@ -550,13 +553,13 @@ void ALSAAudioOutput::run() { snd_pcm_drain(pcm_handle); ALSA_ERRCHECK(snd_pcm_prepare(pcm_handle)); for (unsigned int i = 0; i < buffer_size / period_size; ++i) - ALSA_ERRCHECK(snd_pcm_writei(pcm_handle, zerobuff, period_size)); + ALSA_ERRCHECK(snd_pcm_writei(pcm_handle, zerobuff.data(), period_size)); } if (!stillRun) { snd_pcm_drain(pcm_handle); - while (bRunning && !mix(outbuff, static_cast< unsigned int >(period_size))) { + while (bRunning && !mix(outbuff.data(), static_cast< unsigned int >(period_size))) { this->msleep(10); } @@ -567,9 +570,9 @@ void ALSAAudioOutput::run() { // Fill one frame for (unsigned int i = 0; i < (buffer_size / period_size) - 1; i++) - snd_pcm_writei(pcm_handle, zerobuff, period_size); + snd_pcm_writei(pcm_handle, zerobuff.data(), period_size); - snd_pcm_writei(pcm_handle, outbuff, period_size); + snd_pcm_writei(pcm_handle, outbuff.data(), period_size); } } } diff --git a/src/mumble/AudioInput.cpp b/src/mumble/AudioInput.cpp index 17755e70945..1cf5d26dbbe 100644 --- a/src/mumble/AudioInput.cpp +++ b/src/mumble/AudioInput.cpp @@ -355,7 +355,8 @@ static void inMixerFloatMask(float *RESTRICT buffer, const void *RESTRICT ipt, u const float *RESTRICT input = reinterpret_cast< const float * >(ipt); unsigned int chancount = 0; - STACKVAR(unsigned int, chanindex, N); + std::vector< unsigned int > chanindex; + chanindex.resize(N); for (unsigned int j = 0; j < N; ++j) { if ((mask & (1ULL << j)) == 0) { continue; @@ -379,7 +380,8 @@ static void inMixerShortMask(float *RESTRICT buffer, const void *RESTRICT ipt, u const short *RESTRICT input = reinterpret_cast< const short * >(ipt); unsigned int chancount = 0; - STACKVAR(unsigned int, chanindex, N); + std::vector< unsigned int > chanindex; + chanindex.resize(N); for (unsigned int j = 0; j < N; ++j) { if ((mask & (1ULL << j)) == 0) { continue; diff --git a/src/mumble/AudioOutput.cpp b/src/mumble/AudioOutput.cpp index d8e80e9073a..ef84f3d2a0f 100644 --- a/src/mumble/AudioOutput.cpp +++ b/src/mumble/AudioOutput.cpp @@ -467,14 +467,17 @@ bool AudioOutput::mix(void *outbuff, unsigned int frameCount) { // If the audio backend uses a float-array we can sample and mix the audio sources directly into the output. // Otherwise we'll have to use an intermediate buffer which we will convert to an array of shorts later - STACKVAR(float, fOutput, iChannels *frameCount); - float *output = (eSampleFormat == SampleFloat) ? reinterpret_cast< float * >(outbuff) : fOutput; + std::vector< float > fOutput; + fOutput.resize(iChannels * frameCount); + float *output = (eSampleFormat == SampleFloat) ? reinterpret_cast< float * >(outbuff) : fOutput.data(); memset(output, 0, sizeof(float) * frameCount * iChannels); if (!qlMix.isEmpty()) { // There are audio sources available -> mix those sources together and feed them into the audio backend - STACKVAR(float, speaker, iChannels * 3); - STACKVAR(float, svol, iChannels); + std::vector< float > speaker; + speaker.resize(iChannels * 3); + std::vector< float > svol; + svol.resize(iChannels); bool validListener = false; diff --git a/src/mumble/AudioOutputSample.cpp b/src/mumble/AudioOutputSample.cpp index 50d15749784..5e6c9689c2e 100644 --- a/src/mumble/AudioOutputSample.cpp +++ b/src/mumble/AudioOutputSample.cpp @@ -241,7 +241,8 @@ bool AudioOutputSample::prepareSampleBuffer(unsigned int frameCount) { ceilf(static_cast< float >(frameCount * sfHandle->samplerate()) / static_cast< float >(iOutSampleRate))); unsigned int iInputSamples = iInputFrames * channels; - STACKVAR(float, fOut, iInputSamples); + std::vector< float > fOut; + fOut.resize(iInputSamples); bool eof = false; sf_count_t read; @@ -249,7 +250,7 @@ bool AudioOutputSample::prepareSampleBuffer(unsigned int frameCount) { resizeBuffer(iBufferFilled + sampleCount + INTERAURAL_DELAY); // If we need to resample, write to the buffer on stack - float *pOut = (srs) ? fOut : pfBuffer + iBufferFilled; + float *pOut = (srs) ? fOut.data() : pfBuffer + iBufferFilled; // Try to read all samples needed to satisfy this request if ((read = sfHandle->read(pOut, iInputSamples)) < iInputSamples) { diff --git a/src/mumble/AudioStats.cpp b/src/mumble/AudioStats.cpp index a0d7be9b0e2..a9914bd2eea 100644 --- a/src/mumble/AudioStats.cpp +++ b/src/mumble/AudioStats.cpp @@ -153,10 +153,12 @@ void AudioEchoWidget::paintEvent(QPaintEvent *) { spx_int32_t sz; speex_echo_ctl(ai->sesEcho, SPEEX_ECHO_GET_IMPULSE_RESPONSE_SIZE, &sz); - STACKVAR(spx_int32_t, w, sz); - STACKVAR(float, W, sz); + std::vector< spx_int32_t > w; + w.resize(sz); + std::vector< float > W; + W.resize(sz); - speex_echo_ctl(ai->sesEcho, SPEEX_ECHO_GET_IMPULSE_RESPONSE, w); + speex_echo_ctl(ai->sesEcho, SPEEX_ECHO_GET_IMPULSE_RESPONSE, w.data()); ai->qmSpeex.unlock(); @@ -224,11 +226,13 @@ void AudioNoiseWidget::paintEvent(QPaintEvent *) { spx_int32_t ps_size = 0; speex_preprocess_ctl(ai->sppPreprocess, SPEEX_PREPROCESS_GET_PSD_SIZE, &ps_size); - STACKVAR(spx_int32_t, noise, ps_size); - STACKVAR(spx_int32_t, ps, ps_size); + std::vector< spx_int32_t > noise; + noise.resize(ps_size); + std::vector< spx_int32_t > ps; + ps.resize(ps_size); - speex_preprocess_ctl(ai->sppPreprocess, SPEEX_PREPROCESS_GET_PSD, ps); - speex_preprocess_ctl(ai->sppPreprocess, SPEEX_PREPROCESS_GET_NOISE_PSD, noise); + speex_preprocess_ctl(ai->sppPreprocess, SPEEX_PREPROCESS_GET_PSD, ps.data()); + speex_preprocess_ctl(ai->sppPreprocess, SPEEX_PREPROCESS_GET_NOISE_PSD, noise.data()); ai->qmSpeex.unlock(); @@ -335,11 +339,13 @@ void AudioStats::on_Tick_timeout() { spx_int32_t ps_size = 0; speex_preprocess_ctl(ai->sppPreprocess, SPEEX_PREPROCESS_GET_PSD_SIZE, &ps_size); - STACKVAR(spx_int32_t, noise, ps_size); - STACKVAR(spx_int32_t, ps, ps_size); + std::vector< spx_int32_t > noise; + noise.resize(ps_size); + std::vector< spx_int32_t > ps; + ps.resize(ps_size); - speex_preprocess_ctl(ai->sppPreprocess, SPEEX_PREPROCESS_GET_PSD, ps); - speex_preprocess_ctl(ai->sppPreprocess, SPEEX_PREPROCESS_GET_NOISE_PSD, noise); + speex_preprocess_ctl(ai->sppPreprocess, SPEEX_PREPROCESS_GET_PSD, ps.data()); + speex_preprocess_ctl(ai->sppPreprocess, SPEEX_PREPROCESS_GET_NOISE_PSD, noise.data()); float s = 0.0f; float n = 0.0001f; diff --git a/src/mumble/PulseAudio.cpp b/src/mumble/PulseAudio.cpp index d931890311f..58ca52ac357 100644 --- a/src/mumble/PulseAudio.cpp +++ b/src/mumble/PulseAudio.cpp @@ -595,7 +595,8 @@ void PulseAudioSystem::write_callback(pa_stream *s, size_t bytes, void *userdata pao->eSampleFormat = PulseAudioOutput::SampleShort; pao->iMixerFreq = pss->rate; pao->iChannels = pss->channels; - unsigned int chanmasks[pss->channels]; + std::vector< unsigned int > chanmasks; + chanmasks.resize(pss->channels); for (int i = 0; i < pss->channels; ++i) { unsigned int cm = 0; switch (pcm->map[i]) { @@ -638,22 +639,21 @@ void PulseAudioSystem::write_callback(pa_stream *s, size_t bytes, void *userdata } chanmasks[i] = cm; } - pao->initializeMixer(chanmasks); + pao->initializeMixer(chanmasks.data()); } const unsigned int iSampleSize = pao->iSampleSize; const unsigned int samples = static_cast< unsigned int >(bytes) / iSampleSize; bool oldAttenuation = pas->bAttenuating; - unsigned char buffer[bytes]; + std::vector< unsigned char > buffer; + buffer.resize(bytes); // do we have some mixed output? - if (pao->mix(buffer, samples)) { + if (pao->mix(buffer.data(), samples)) { // attenuate if instructed to or it's in settings pas->bAttenuating = (Global::get().bAttenuateOthers || Global::get().s.bAttenuateOthers); } else { - memset(buffer, 0, bytes); - // attenuate if intructed to (self-activated) pas->bAttenuating = Global::get().bAttenuateOthers; } @@ -663,7 +663,7 @@ void PulseAudioSystem::write_callback(pa_stream *s, size_t bytes, void *userdata pas->setVolumes(); } - pa.stream_write(s, buffer, iSampleSize * samples, nullptr, 0, PA_SEEK_RELATIVE); + pa.stream_write(s, buffer.data(), iSampleSize * samples, nullptr, 0, PA_SEEK_RELATIVE); } void PulseAudioSystem::volume_sink_input_list_callback(pa_context *c, const pa_sink_input_info *i, int eol, diff --git a/src/mumble/ServerHandler.cpp b/src/mumble/ServerHandler.cpp index 22e03cfd138..05c56b91803 100644 --- a/src/mumble/ServerHandler.cpp +++ b/src/mumble/ServerHandler.cpp @@ -290,7 +290,8 @@ void ServerHandler::handleVoicePacket(const Mumble::Protocol::AudioData &audioDa } void ServerHandler::sendMessage(const unsigned char *data, int len, bool force) { - STACKVAR(unsigned char, crypto, len + 4); + std::vector< unsigned char > crypto; + crypto.resize(len + 4); QMutexLocker qml(&qmUdp); @@ -314,10 +315,10 @@ void ServerHandler::sendMessage(const unsigned char *data, int len, bool force) QApplication::postEvent(this, new ServerHandlerMessageEvent(qba, Mumble::Protocol::TCPMessageType::UDPTunnel, true)); } else { - if (!connection->csCrypt->encrypt(reinterpret_cast< const unsigned char * >(data), crypto, len)) { + if (!connection->csCrypt->encrypt(reinterpret_cast< const unsigned char * >(data), crypto.data(), len)) { return; } - qusUdp->writeDatagram(reinterpret_cast< const char * >(crypto), len + 4, qhaRemote, usResolvedPort); + qusUdp->writeDatagram(reinterpret_cast< const char * >(crypto.data()), len + 4, qhaRemote, usResolvedPort); } } diff --git a/src/mumble/main.cpp b/src/mumble/main.cpp index 9daee17ef8f..bcad6c57e9f 100644 --- a/src/mumble/main.cpp +++ b/src/mumble/main.cpp @@ -467,7 +467,8 @@ int main(int argc, char **argv) { if (_wgetenv_s(&reqSize, nullptr, 0, L"PATH") != 0) { qWarning() << "Failed to get PATH. Not adding application directory to PATH. DBus bindings may not work."; } else if (reqSize > 0) { - STACKVAR(wchar_t, buff, reqSize + 1); + std::vector< wchar_t > buff; + buff.resize(reqSize + 1); if (_wgetenv_s(&reqSize, buff, reqSize, L"PATH") != 0) { qWarning() << "Failed to get PATH. Not adding application directory to PATH. DBus bindings may not work."; diff --git a/src/mumble/os_win.cpp b/src/mumble/os_win.cpp index 1b0acf33499..fd7ebe74d5d 100644 --- a/src/mumble/os_win.cpp +++ b/src/mumble/os_win.cpp @@ -174,7 +174,8 @@ FARPROC WINAPI delayHook(unsigned dliNotify, PDelayLoadInfo pdli) { size_t buflen = length + 10; - STACKVAR(char, filename, buflen); + std::vector< char > filename; + filename.resize(buflen); strcpy_s(filename, buflen, pdli->szDll); size_t offset = 0; diff --git a/src/murmur/Server.cpp b/src/murmur/Server.cpp index 55682804a9f..0519fb4fc59 100644 --- a/src/murmur/Server.cpp +++ b/src/murmur/Server.cpp @@ -742,7 +742,8 @@ void Server::run() { #ifdef Q_OS_UNIX socklen_t fromlen; - STACKVAR(struct pollfd, fds, nfds + 1); + std::vector< struct pollfd > fds; + fds.resize(nfds + 1); for (int i = 0; i < nfds; ++i) { fds[i].fd = qlUdpSocket.at(i); @@ -755,8 +756,10 @@ void Server::run() { fds[nfds].revents = 0; #else int fromlen; - STACKVAR(SOCKET, fds, nfds); - STACKVAR(HANDLE, events, nfds + 1); + std::vector< SOCKET > fds; + fds.resize(nfds); + std::vector< HANDLE > events; + events.resize(nfds + 1); for (int i = 0; i < nfds; ++i) { fds[i] = qlUdpSocket.at(i); events[i] = CreateEvent(nullptr, FALSE, FALSE, nullptr); @@ -771,7 +774,7 @@ void Server::run() { FrameMarkNamed(TracyConstants::UDP_FRAME); #ifdef Q_OS_UNIX - int pret = poll(fds, nfds, -1); + int pret = poll(fds.data(), nfds, -1); if (pret <= 0) { if (errno == EINTR) continue; @@ -1013,10 +1016,12 @@ void Server::sendMessage(ServerUser &u, const unsigned char *data, int len, QByt if ((u.aiUdpFlag.load() == 1 || force) && (u.sUdpSocket != INVALID_SOCKET)) { #endif #if defined(__LP64__) - STACKVAR(char, ebuffer, len + 4 + 16); - char *buffer = reinterpret_cast< char * >(((reinterpret_cast< quint64 >(ebuffer) + 8) & ~7) + 4); + std::vector< char > ebuffer; + ebuffer.resize(len + 4 + 16); + char *buffer = reinterpret_cast< char * >(((reinterpret_cast< quint64 >(ebuffer.data()) + 8) & ~7) + 4); #else - STACKVAR(char, buffer, len + 4); + std::vector< char > buffer; + buffer.resize(len + 4); #endif { QMutexLocker wl(&u.qmCrypt); diff --git a/src/tests/TestCrypt/TestCrypt.cpp b/src/tests/TestCrypt/TestCrypt.cpp index 1c768c06c19..9078141b3e9 100644 --- a/src/tests/TestCrypt/TestCrypt.cpp +++ b/src/tests/TestCrypt/TestCrypt.cpp @@ -191,17 +191,20 @@ void TestCrypt::authcrypt() { CryptStateOCB2 cs; cs.setKey(rawkey_str, nonce_str, nonce_str); - STACKVAR(unsigned char, src, len); + std::vector< unsigned char > src; + src.resize(len); for (int i = 0; i < len; i++) src[i] = (i + 1); unsigned char enctag[AES_BLOCK_SIZE]; unsigned char dectag[AES_BLOCK_SIZE]; - STACKVAR(unsigned char, encrypted, len); - STACKVAR(unsigned char, decrypted, len); + std::vector< unsigned char > encrypted; + encrypted.resize(len); + std::vector< unsigned char > decrypted; + decrypted.resize(len); - QVERIFY(cs.ocb_encrypt(src, encrypted, len, nonce, enctag)); - QVERIFY(cs.ocb_decrypt(encrypted, decrypted, len, nonce, dectag)); + QVERIFY(cs.ocb_encrypt(src.data(), encrypted.data(), len, nonce, enctag)); + QVERIFY(cs.ocb_decrypt(encrypted.data(), decrypted.data(), len, nonce, dectag)); for (int i = 0; i < AES_BLOCK_SIZE; i++) QCOMPARE(enctag[i], dectag[i]); @@ -222,26 +225,28 @@ void TestCrypt::xexstarAttack() { CryptStateOCB2 cs; cs.setKey(rawkey_str, nonce_str, nonce_str); - STACKVAR(unsigned char, src, 2 * AES_BLOCK_SIZE); + std::vector< unsigned char > src; + src.resize(2 * AES_BLOCK_SIZE); // Set first block to `len(secondBlock)` - memset(src, 0, AES_BLOCK_SIZE); src[AES_BLOCK_SIZE - 1] = AES_BLOCK_SIZE * 8; // Set second block to arbitrary value - memset(src + AES_BLOCK_SIZE, 42, AES_BLOCK_SIZE); + memset(src.data() + AES_BLOCK_SIZE, 42, AES_BLOCK_SIZE); unsigned char enctag[AES_BLOCK_SIZE]; unsigned char dectag[AES_BLOCK_SIZE]; - STACKVAR(unsigned char, encrypted, 2 * AES_BLOCK_SIZE); - STACKVAR(unsigned char, decrypted, 2 * AES_BLOCK_SIZE); + std::vector< unsigned char > encrypted; + encrypted.resize(2 * AES_BLOCK_SIZE); + std::vector< unsigned char > decrypted; + decrypted.resize(2 * AES_BLOCK_SIZE); - const bool failed_encrypt = !cs.ocb_encrypt(src, encrypted, 2 * AES_BLOCK_SIZE, nonce, enctag, false); + const bool failed_encrypt = !cs.ocb_encrypt(src.data(), encrypted.data(), 2 * AES_BLOCK_SIZE, nonce, enctag, false); // Perform the attack encrypted[AES_BLOCK_SIZE - 1] ^= AES_BLOCK_SIZE * 8; for (int i = 0; i < AES_BLOCK_SIZE; ++i) enctag[i] = src[AES_BLOCK_SIZE + i] ^ encrypted[AES_BLOCK_SIZE + i]; - const bool failed_decrypt = !cs.ocb_decrypt(encrypted, decrypted, 1 * AES_BLOCK_SIZE, nonce, dectag); + const bool failed_decrypt = !cs.ocb_decrypt(encrypted.data(), decrypted.data(), 1 * AES_BLOCK_SIZE, nonce, dectag); // Verify forged tag (should match if attack is properly implemented) for (int i = 0; i < AES_BLOCK_SIZE; ++i) { @@ -256,8 +261,8 @@ void TestCrypt::xexstarAttack() { // since digital silence appears to produce them in mass. // So instead we now modify the packet in a way which should not affect the audio but will // prevent the attack. - QVERIFY(cs.ocb_encrypt(src, encrypted, 2 * AES_BLOCK_SIZE, nonce, enctag)); - QVERIFY(cs.ocb_decrypt(encrypted, decrypted, 2 * AES_BLOCK_SIZE, nonce, dectag)); + QVERIFY(cs.ocb_encrypt(src.data(), encrypted.data(), 2 * AES_BLOCK_SIZE, nonce, enctag)); + QVERIFY(cs.ocb_decrypt(encrypted.data(), decrypted.data(), 2 * AES_BLOCK_SIZE, nonce, dectag)); // Tags should match for (int i = 0; i < AES_BLOCK_SIZE; ++i) { @@ -282,16 +287,18 @@ void TestCrypt::tamper() { const unsigned char msg[] = "It was a funky funky town!"; int len = sizeof(msg); - STACKVAR(unsigned char, encrypted, len + 4); - STACKVAR(unsigned char, decrypted, len); - cs.encrypt(msg, encrypted, len); + std::vector< unsigned char > encrypted; + encrypted.resize(len + 4); + std::vector< unsigned char > decrypted; + decrypted.resize(len); + cs.encrypt(msg, encrypted.data(), len); for (int i = 0; i < len * 8; i++) { encrypted[i / 8] ^= 1 << (i % 8); - QVERIFY(!cs.decrypt(encrypted, decrypted, len + 4)); + QVERIFY(!cs.decrypt(encrypted.data(), decrypted.data(), len + 4)); encrypted[i / 8] ^= 1 << (i % 8); } - QVERIFY(cs.decrypt(encrypted, decrypted, len + 4)); + QVERIFY(cs.decrypt(encrypted.data(), decrypted.data(), len + 4)); } QTEST_MAIN(TestCrypt)