Commit graph

879 commits

Author SHA1 Message Date
Michael Meeks
7183a3d3de spdx: improve machine and human readability of headers.
Change-Id: Ice934380029bf27054e830fffc07a5d037d1430f
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
2023-11-14 19:36:31 +00:00
Michael Meeks
08d9081280 net: don't try to set TCP_NODELAY on local Unix sockets.
Change-Id: Ic0f720554080a01b7a46abbffda023834016c0ea
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
2023-11-01 08:06:53 +00:00
Caolán McNamara
e0c161c17b These warnings are frequent but harmless
Signed-off-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Change-Id: Id2517f310a1df71dc1357d103ea074bdd12e7e65
2023-10-25 20:08:20 +02:00
Ashod Nakashian
184a4a522e killpoco: replace HTTPResponse in sendFileAndShutdown
We now use our http::Response in HttpHelper::sendFileAndShutdown.

Change-Id: I77503fce7a66a11435bad896d3d5d6df611544be
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-10-24 21:33:02 -04:00
Ashod Nakashian
c3fb1d0dde wsd: helper to serialize pairs
Since we don't want to propagate Poco types
as well as our pair containers, it's best
to have these are named functions rather
than as operator<<.

Change-Id: I9772b8f314262147b6c445464bf3ce8cb598b56d
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-10-24 21:33:02 -04:00
Ashod Nakashian
6ed5dc9a64 wsd: http: no need to pass the mime-type explicitly to sendFile
Since we already have an http response instance (in all but
one case, prior to this change), there is no need to pass
the mime-type explicitly to the sendFileAndShutdown
function, only to set it on the http response.

There are already too many arguments and the mime-type
is surely redundant.

Change-Id: Iab64074dc111573b87fb8fa9b907c26a4160910c
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-10-24 21:33:02 -04:00
Ashod Nakashian
0c59eda780 wsd: http: use named HTTP status-code instead of naked int
Self-documenting, less error-prone, and searchable.

Change-Id: Ifc21d7cf5512d9a63c5d5bc10ebc003fcccc93c1
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-10-24 21:33:02 -04:00
Ashod Nakashian
7e1a23f47a wsd: test: helper to wait for any of the given messages
Change-Id: Ice48f59202306134dbafb411b8078f416e56b1c0
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-10-24 09:20:32 +02:00
Ashod Nakashian
7e105e1651 wsd: log TCP_NODELAY error only once
It seems that when TCP_NODELAY fails to be set,
the failure is permanent. As such, there is no
point in filling the logs with the same error.

This patch logs the error only once, per process,
and supresses further logs from Socket::setNoDelay().

Change-Id: I52c6b8cca35a8c281b4c4639d61a7e2521775d49
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-10-23 21:22:15 +01:00
Caolán McNamara
3d942b4d09 cid#318905 Untrusted allocation size
rearrange so coverity can see the size check

Signed-off-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Change-Id: Ifad60b1a2aba2cf9c6cfbf4ea8e450b9846de576
2023-10-20 17:01:47 +02:00
Caolán McNamara
c6b0eebbf8 cid#329408 Unchecked return value from library
Signed-off-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Change-Id: Id034ba2e1ca9d4d3d7f7722b929063cee2f7d4e3
2023-10-17 09:48:02 +02:00
Caolán McNamara
960938e000 cid#318957 Unchecked return value from library
Signed-off-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Change-Id: I5bd471f86668d9fbd72cfb050fb67df6d70bdc9f
2023-10-16 09:37:01 +02:00
Caolán McNamara
8d42849156 ProcSMapsFile might not be a valid file descriptor
in which case don't send it, which then implies we might have
an empty shareFDs which we can treat the same as a nonexisting
shareFDs

Signed-off-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Change-Id: I80a78a01c69dbee5ee28a64442a5069a6c2b4dbe
2023-10-14 12:56:15 +01:00
Skyler Grey
2666063040 Allow http Range header for media files
The range header allows a client to specify that they would like only
part of a file, e.g. only the first 1000 bytes of a video. When playing
video on Apple devices (Macs, iPads, iPhones etc.) this is required to
avoid Safari rejecting the video as broken. This is the first part of a
fix to embedded videos on Safari.

This commit does not implement specifying multiple ranges at once (e.g.
bytes=0-9,-100 to get the first 10 and last 100 bytes).

This feature is necessary to play video on Apple devices, but it is not
sufficient. In particular, I believe some further client-side fixes will
be needed to make the video play properly.

Signed-off-by: Skyler Grey <skyler.grey@collabora.com>
Change-Id: Id89a06d374b7d0efbf2b3184d8618df61684dcb6
2023-10-11 15:09:15 +00:00
Caolán McNamara
672f3cee2c rework URP to use a dedicated channel
Instead of fighting the SolarMutex to get the messages
processed by the main loop. Simple and no additional
threading, mutexes etc.

messages from the external uno client are just
written to URPtoLoFD and the core reads from that

messages to the external uno client are written
to URPfromLoFD by core, that fd is in poll, and
activity there triggers a read by the DocBroker
to send it to the external uno client.

Signed-off-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Change-Id: Ib1f0a0d5fb5ab22eee476d5d740b290c51de59dc
2023-10-03 10:15:55 +01:00
Miklos Vajna
a0944a0b5e Fix the --enable-fuzzers build
Failed with:

	fuzzer/HttpEcho.cpp:111:17: error: 'removeSockets' is a private member of 'SocketPoll'

And:

	kit/Delta.hpp:208:(.text._ZN14DeltaGenerator14DeltaBitmapRow7initRowEPKjj[_ZN14DeltaGenerator14DeltaBitmapRow7initRowEPKjj]+0x127): undefined reference to `simd_initPixRowSimd'

Signed-off-by: Miklos Vajna <vmiklos@collabora.com>
Change-Id: I6d980698b43ca3545d9eae5f40eabaf4e442ca17
2023-10-02 20:15:42 +01:00
Ashod Nakashian
57a9cf053a wsd: support EnableExperimental in Log
Now that we depend on EnableExperimental in Log.cpp,
we must define it in the standalone binaries that
otherwise don't define it.

Change-Id: Ic56032eaf6df7d0d5d707a60eeddf2d75c9041ac
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-10-02 20:14:53 +01:00
Caolán McNamara
b25d7617d6 cid#318824 avoid Calling risky function warning
Signed-off-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Change-Id: I871035b7879157467b97e5610a38d0b53f934766
2023-10-02 08:30:42 +02:00
Caolán McNamara
ed59e9e3b0 cid#318948 Unchecked return value from library
Signed-off-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Change-Id: I543f7150c23fe6a6cffc3333754e413ee4c190a4
2023-10-02 08:30:42 +02:00
Caolán McNamara
dd2f0e26f6 cid#318881 Unchecked return value from library
Signed-off-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Change-Id: I6c02e392a96717c4ebc6f50e56bcec553aa328bb
2023-10-02 08:30:42 +02:00
Ashod Nakashian
4865eff4a0 wsd: improved assertion
Change-Id: I8d65850415f62a6b1680d6638b0639f2642d95e8
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-09-25 19:29:12 -04:00
Caolán McNamara
e3cfc935ff cid#318907 silence Uncaught exception
silence various of these in tests and utilities

Signed-off-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Change-Id: I4fcc95b1b5d5c95e5ac40782550f95c08a3467bd
2023-08-24 08:30:40 +02:00
Caolán McNamara
461fe6a630 cid#318940 Big parameter passed by value
newRequest is always called with a const Request& already so might as
well make this copy inside the function rather than passing a copy
by value and moving it.

Signed-off-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Change-Id: Ib572637d29590b8b470a42da3293065ed86d7dd0
2023-08-15 15:09:36 +02:00
Caolán McNamara
5dcf65f5c6 cid#318893 COPY_INSTEAD_OF_MOVE
Signed-off-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Change-Id: Ia478c77645c49b8c5d976407fcf6780cace7f211
2023-08-15 15:09:36 +02:00
Caolán McNamara
6062342827 cid#318980 COPY_INSTEAD_OF_MOVE
iss ctor takes a const std::string& and constructs with a copy of str as content

Signed-off-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Change-Id: I2805c869cb034a9b87e6e95cc58419b54a078b63
2023-08-15 08:21:44 +02:00
Caolán McNamara
b6f87b06e3 cid#322475 COPY_INSTEAD_OF_MOVE
configure currently requires a min of c++17

Signed-off-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Change-Id: I613dac6e66c3e77183d46623346969179bccc489
2023-08-10 08:47:25 +02:00
Caolán McNamara
6d873d6837 cid#318919 Dereference after null check
map is never null so make it a reference

Signed-off-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Change-Id: I9f6ad863d0a1102dd7e26a5668b1c6ba71249580
2023-08-09 13:39:23 +02:00
Caolán McNamara
9e0b0a0c85 cid#318909 Argument cannot be negative
and

cid#318961 Argument cannot be negative

Signed-off-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Change-Id: I4bae768a3c72361309b84b624c019a315b574d97
2023-08-04 10:17:58 +02:00
Ashod Nakashian
5b52f7d8eb wsd: smart pointer cleanup
std::make_shared and std::make_unique
are superior to explict smart pointer
construction. Where we have private
constructors, we can't use them.

Change-Id: I492122f58e958113c6e6d31445c6614ad98c89aa
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-08-03 08:40:20 +02:00
Ashod Nakashian
67dd4e4a9d wsd: test: new cool.html post request test
Using our own http library, we request
cool.html with realistic parameters and
validate many key values sent in the
request.

Change-Id: Ie3c0ac042f64bf5d6ed21354a33efac801b32846
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-08-03 08:40:20 +02:00
Michael Meeks
03d83ab6b8 paste: cleanup excessive debugging.
We don't want to dump the whole paste buffer as hex, or indeed any
large mis-encoded string - instead crop to the problematic section
for easier debugging, and no performance hit.

Change-Id: I30518beea436895a42b3429c3cb6e16e2093cca9
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
2023-07-28 21:38:02 +01:00
Michael Meeks
85152bf953 Typos: wake-up.
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
Change-Id: I8ae12c8c8390997bbde7af1e203e9075dfa4ea25
2023-07-17 11:35:25 +02:00
Szymon Kłos
3d6ed28857 Fix pasting image assertion
Revert "Avoid crash when pasting image in debug mode"
This reverts commit 78558fe9af.

Instead of detecting paste command and not trigerring assertion:
fix frame type so it will be binary in case of paste.

Signed-off-by: Szymon Kłos <szymon.klos@collabora.com>
Change-Id: If5c726463459be7eaffae1522df522dfa1d74443
2023-07-13 20:06:58 +02:00
Ashod Nakashian
5e343d9ffb wsd: serialize the http status-code numerically too
Change-Id: Ia5d67f295ce0426b160b64b72399950cc3723d7b
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-07-08 04:19:00 -04:00
Ashod Nakashian
4453175348 wsd: improved socket dump state
Change-Id: I5b59461b17a8d94d955cdeff5b6ebbf1573db0bf
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-07-08 04:19:00 -04:00
luigiiucci
78558fe9af Avoid crash when pasting image in debug mode
If COOL is running in debug mode ther is a
check that incoming messages are UTF-8.
We skip this tests if the message refers
to an image pasted.

Signed-off-by: luigiiucci <luigi.iucci@collabora.com>
Change-Id: I4f7e4a647deb22ec2a032d4d6347d910184c0701
2023-07-04 09:57:52 +02:00
Ashod Nakashian
481d3b6842 wsd: http: avoid capturing locals by reference
Fortunately, we have no need for any locals
in this case.

Change-Id: I954953bb2a8c79662152ad4cc2fb5422bc2b0baa
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-06-30 21:45:40 +02:00
Ashod Nakashian
5e27d0800b wsd: use STATE_ENUM in SocketDisposition
Change-Id: I914557afdbf8f03856214acf2a64d405b8e0e068
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-06-30 21:45:40 +02:00
Ashod Nakashian
56992f0bad wsd: logging
Change-Id: Id82e44f508397affbc828494c766dca7bb97d4dd
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-06-30 21:45:40 +02:00
Ashod Nakashian
826451b6cf wsd: http: protect against exceptions from onFinish
Previously, we didn't expect such exceptions,
but increasingly this can happen, as we have
more and more async processing. The main
issue with not catching exceptions is that
we do not properly discard read and
parsed data from the socket. This is a
major issue, of course.

Change-Id: I4490baed7069cd55d103301c1d3be31d9b2d9b2c
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-06-30 21:45:40 +02:00
Caolán McNamara
c7c2644b9b fix android ci
github_android_online_co-23.05/net/HttpRequest.hpp:1391:63: error: no matching function for call to 'min'
                      << Util::dumpHex(std::string(data.data(), std::min(data.size(), 256UL))));
                                                                ^~~~~~~~

Signed-off-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Change-Id: I5b81096c696565b9e4eb4f3ca39c16bc1e5b9182
2023-06-26 17:07:35 +01:00
Michael Meeks
1cf561d0ef Restore commit 80b4e6d4ae
Remove un-necessary gating of wakeup() on stop un-related to
callbacks or new sockets.

This reverts commit 25f2581a30.

Change-Id: I9f9f30fed34c973b86206677168071abb81afa6f
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
2023-06-16 16:08:42 +01:00
Patrick Luby
e381b9194e Implement minor changes suggested during review
Signed-off-by: Patrick Luby <plubius@neooffice.org>
Change-Id: Id25c8a9deec35b9ae74ed1cc8a9dcf88dc5486cc
2023-06-15 19:01:42 +01:00
Patrick Luby
57a9db5664 Replace preprocessor directives with C++ conditional check
UnitBase::isUnitTesting() and UnitWSD::isUnitTesting() to avoid
calling methods that crash on mobile.

Signed-off-by: Patrick Luby <plubius@neooffice.org>
Change-Id: Ie6bc2d238ac9e475b02ceef5809c55acc129dd52
2023-06-15 19:01:42 +01:00
Patrick Luby
12213d7ec5 Fix iOS build breakages by adding http::Request to iOS build
Still needed to add a bunch of #if !MOBILAPP to disable all of the
Online server's unit testing classes so that the iOS app won't crash
when opening a document.

TODO: the iOS app will not accept text input at all. Is some code
unexpectedly consuming message data sent over the mobile fake socket?

Signed-off-by: Patrick Luby <plubius@neooffice.org>
Change-Id: Ie874ee8e452188a7b4cdf6d5f87708e5ed9b0235
2023-06-15 19:01:42 +01:00
Ashod Nakashian
40a915ab4d wsd: thread-safe socket shutdown flag
Change-Id: I1f0b5be698b0e4a1cb55edf65eb706f181cd8516
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-06-14 07:04:26 -04:00
Caolán McNamara
2f9c9396d3 cid#318856 Uninitialized scalar field
Signed-off-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Change-Id: I2a6c3e9d021884b898f9efdc51c528428321d6f0
2023-06-14 10:10:46 +02:00
Caolán McNamara
88df33d467 cid#318915 Uninitialized scalar field
Signed-off-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Change-Id: Ia93efc031d6072e97f90136f93dcaff03af934cc
2023-06-14 10:10:46 +02:00
Caolán McNamara
b68634db9a cid#318867 Using a moved object
probably went astray with:

commit 52f2600cf9
Date:   Wed Feb 16 17:22:18 2022 -0500

    wsd: test: embue all tests with a name and unify logs

Signed-off-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Change-Id: Idf4f9bfce7ef188ac15a7cf62baadc3dd5b59dcd
2023-06-14 10:10:46 +02:00
Michael Meeks
25f2581a30 Revert this for now while we think more deeply.
This reverts commit 80b4e6d4ae.
2023-06-09 09:19:36 +01:00