Coverage Report

Created: 2026-10-28 07:03

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/qpdf/libqpdf/Pl_RC4.cc
Line
Count
Source
1
#include <qpdf/Pl_RC4.hh>
2
3
#include <qpdf/QUtil.hh>
4
#include <qpdf/Util.hh>
5
6
using namespace qpdf;
7
8
Pl_RC4::Pl_RC4(char const* identifier, Pipeline* next, std::string key, size_t out_bufsize) :
9
4.17k
    Pipeline(identifier, next),
10
4.17k
    out_bufsize(out_bufsize),
11
4.17k
    rc4(reinterpret_cast<unsigned char const*>(key.data()), static_cast<int>(key.size()))
12
4.17k
{
13
4.17k
    util::assertion(next, "Attempt to create Pl_RC4 with nullptr as next");
14
4.17k
    this->outbuf = QUtil::make_shared_array<unsigned char>(out_bufsize);
15
4.17k
}
16
17
void
18
Pl_RC4::write(unsigned char const* data, size_t len)
19
4.17k
{
20
4.17k
    util::assertion(outbuf.get(), "Pl_RC4: write() called after finish() called");
21
22
4.17k
    size_t bytes_left = len;
23
4.17k
    unsigned char const* p = data;
24
25
8.39k
    while (bytes_left > 0) {
26
4.21k
        size_t bytes = (bytes_left < this->out_bufsize ? bytes_left : out_bufsize);
27
4.21k
        bytes_left -= bytes;
28
4.21k
        rc4.process(p, bytes, outbuf.get());
29
4.21k
        p += bytes;
30
4.21k
        next()->write(outbuf.get(), bytes);
31
4.21k
    }
32
4.17k
}
33
34
void
35
Pl_RC4::finish()
36
4.17k
{
37
4.17k
    outbuf = nullptr;
38
4.17k
    next()->finish();
39
4.17k
}