]> git.tuebingen.mpg.de Git - paraslash.git/log
paraslash.git
13 days agoMerge topic branch t/sf_float into pu pu
Andre Noll [Fri, 19 Apr 2024 18:45:36 +0000 (20:45 +0200)]
Merge topic branch t/sf_float into pu

A single patch which adds two new sample formats for 32 bit IEEE
float waveform data.

<!--

- The alsa writer also supports 32 bit float sample formats.

-->

* refs/heads/t/sf_float:
  New audio formats: 32 bit float (little and big endian).

13 days agoMerge topic branch t/play into pu
Andre Noll [Fri, 19 Apr 2024 18:45:34 +0000 (20:45 +0200)]
Merge topic branch t/play into pu

This small series contains a few minor tweaks for para_play. The most
obvious change is that para_play is no longer built on systems which
lack libreadline.

<!--
- para_play is no longer built if libreadline is not installed.
-->

* refs/heads/t/play:
  play: Shut down alsa on input EOF.
  play: Simplify and improve get_key_map_seq().
  play: Remove pointless goto in play_post_monitor().
  Return from filter_setup() so callers can reset the terminal.
  Let para_play depend on libreadline.

# Conflicts:
# configure.ac

13 days agoMerge topic branch t/openssl-3 into pu
Andre Noll [Fri, 19 Apr 2024 18:43:28 +0000 (20:43 +0200)]
Merge topic branch t/openssl-3 into pu

Started on 2023-04-29.

The series starts with a few cleanups and crypto-backend tweaks to
beat the openssl specific code into shape for the main objective:
the switch of the RSA encryption and decryption routines to the
high-level EVP API. This has become necessary because the old RSA
API functions have been deprecated in openssl-3.

<!--

- The openssl RSA code has been converted to EVP and no longer uses
  any deprecated openssl API functions.

-->

* refs/heads/t/openssl-3:
  openssl: Reactivate openssl warnings.
  openssl: Use the EVP library for RSA private decryption.
  openssl: Use the EVP library for RSA public encryption.
  apc_priv_decrypt: Let the callee allocate the buffer.
  apc_pub_encrypt: Let the callee allocate the buffer.
  openssl: Assume that openssl allocation functions functions succeed.
  openssl: Introduce openssl_perror().
  openssl: Don't pass pointers to RSA structures around.
  openssl: Kill rsa coefficient computations.
  client: Check buffer size returned by apc_priv_decrypt().

# Conflicts:
# configure.ac

13 days agoMerge topic branch t/misc into pu
Andre Noll [Fri, 19 Apr 2024 18:43:26 +0000 (20:43 +0200)]
Merge topic branch t/misc into pu

The stuff in here is too small to get its own topic branch. The
commits are generally regarded as safe enough to be applied directly to
"master" without cooking in "next" first. However, if a commit induces
a merge conflict or is important enough to get mentioned in an item
of the NEWS file, the commit should get a dedicated topic branch.

Unlike most other topic branches, this branch never promotes to
"next". When a set of commits is ready to graduate to "master", the
branch is rebased onto "master" and its commits are re-ordered so that
the graduating commits appear at the beginning. The last such commit
is merged to "master". This always results in a fast-forward merge,
so no merge message needs to be supplied.

* refs/heads/t/misc:
  client: Fix memory leak on exit.
  ipc: Remove pointless initialization in shm_get_shmmax().
  i9e: Clear history on close.

13 days agoMerge topic branch t/ls-l into pu
Andre Noll [Fri, 19 Apr 2024 18:43:26 +0000 (20:43 +0200)]
Merge topic branch t/ls-l into pu

Started on 2024-03-17

A single commit which deprecates the chunk table and mbox listing
modes. The chunk table can still be listed with para_afh(1), and the
mbox format was never really useful to begin with. The idea is to
remove support after 0.8.0 has been released.

<!--
- The chunk table and mbox listing modes of the ls server command
have been deprecated. They still work, but a warning is issued to
inform the user about the deprecated option.
-->

* refs/heads/t/ls-l:
  server: Deprecate -l=c and -l=m of com_ls().

13 days agoMerge topic branch t/home into pu
Andre Noll [Fri, 19 Apr 2024 18:43:26 +0000 (20:43 +0200)]
Merge topic branch t/home into pu

Started on 2024-03-20

* refs/heads/t/home:
  f
  Replace get_homedir() by get_confdir().
  Consult $HOME rather than calling getpwuid(),

13 days agoMerge topic branch t/for-maint into pu
Andre Noll [Fri, 19 Apr 2024 18:43:25 +0000 (20:43 +0200)]
Merge topic branch t/for-maint into pu

This branch accumulates small but significant hotfixes for known bugs
in the most stable integration branch, "maint". Only serious issues
are fixed here, and no development takes place on this branch.

The purpose of the branch is to give such urgent fixes at least
a small amount of testing in pu before they are incorporated into
maint. During this time the patch can be tweaked, and the documentation
can be improved. Usually the commits of this branch are merged quickly,
however, and it it perfectly normal if this branch is empty.

* refs/heads/t/for-maint:
  play: Fix integer overflow in com_ff().

13 days agoMerge topic branch t/btr into pu
Andre Noll [Fri, 19 Apr 2024 18:43:25 +0000 (20:43 +0200)]
Merge topic branch t/btr into pu

Some helpers such as btr_get_input_queue_size() are very expensive
if the buffer tree contains many buffers, which is the case for mp3
and aac streams. This is noticeable in particular with para_play,
which spends more time in the btr subsystem than in the mp3 decoder
if the file is large enough. This branch contains a few patches to
improve that.

<!--
- Speedups for the buffer tree code, which particularly improves the
performance of para_play for large mp3 mp4 files.
-->

* refs/heads/t/btr:
  btr: Streamline the documentation of buffer_tree.h.
  Constify buffer tree API.
  btr: Merge buffers on insertion.
  btr: Speed up btr_node_status().
  Speed up mp3dec filter.

13 days agoplay: Shut down alsa on input EOF.
Andre Noll [Thu, 6 Oct 2022 14:11:55 +0000 (16:11 +0200)]
play: Shut down alsa on input EOF.

para_play leaks a lot of memory on exit because we didn't bother
to shut down the alsa subsystem. While this is harmless from the
correctness point of view, it does make it harder to spot real
memory leaks.

Rework the error handling to always shut down alsa via kill_stream().
Combine play_post_monitor() and session_post_monitor() because they
are small enough and the latter was badly named anyway.

13 days agoplay: Simplify and improve get_key_map_seq().
Andre Noll [Sun, 25 Jun 2023 12:29:07 +0000 (14:29 +0200)]
play: Simplify and improve get_key_map_seq().

Combine it with get_user_key_map_seq() and replace the NULL check
with an assertion since the condition can never be true here. This
makes gcc's static analyzer happy, which complained about a possible
NULL pointer dereference.

13 days agoplay: Remove pointless goto in play_post_monitor().
Andre Noll [Wed, 14 Jun 2023 20:33:39 +0000 (22:33 +0200)]
play: Remove pointless goto in play_post_monitor().

We may as well return directly.

13 days agoReturn from filter_setup() so callers can reset the terminal.
Andre Noll [Wed, 23 Nov 2022 18:21:25 +0000 (19:21 +0100)]
Return from filter_setup() so callers can reset the terminal.

This function of filter_common.c calls exit(3) on errors. This is OK
for para_filter and para_audiod, but not for para_play because there
the function is called after readline has initialized the terminal for
its own use. If the function calls exit(3), the terminal settings are
not reset as they should have been. This can be observed for example
on the attempt to open an mp3 file with an para_play executable that
lacks mp3 support.

This commit changes the function to return an error code instead and
deals with the fallout in the three callers. Although play.c already
had error checking for calls to filter_setup(), it still needs a minor
tweak because we now have to deal with the fact that the filter and
writer node don't exist in eof_cleanup().

13 days agoLet para_play depend on libreadline.
Andre Noll [Wed, 5 Oct 2022 18:22:17 +0000 (20:22 +0200)]
Let para_play depend on libreadline.

While para_client and para_audioc are suitable for non-interactive
use, e.g. in scripts, para_play can only be used interactively,
and its non-readline version is barely usable.

Rather than building a crippled version, teach the build and test
systems to skip para_play if the readline library is not installed.

13 days agoplay: Fix integer overflow in com_ff().
Andre Noll [Fri, 19 Apr 2024 18:35:02 +0000 (20:35 +0200)]
play: Fix integer overflow in com_ff().

The product of the number of chunks and the number of seconds to skip
may overflow the 32 bit multiplication. Add a cast to force 64 bit
arithmetics to avoid the overflow.

5 weeks agof
Andre Noll [Thu, 21 Mar 2024 16:27:44 +0000 (17:27 +0100)]
f

6 weeks agoclient: Fix memory leak on exit.
Andre Noll [Thu, 21 Mar 2024 11:39:06 +0000 (12:39 +0100)]
client: Fix memory leak on exit.

This triggers only if para_client is run interactively. The leak is
harmless, but still..

6 weeks agoReplace get_homedir() by get_confdir().
Andre Noll [Wed, 20 Mar 2024 16:24:28 +0000 (17:24 +0100)]
Replace get_homedir() by get_confdir().

Every single caller of get_homedir() uses the returned string to
create a path below ~/.paraslash, so we might as well return this path,
simplifying the callers.

6 weeks agoConsult $HOME rather than calling getpwuid(),
Andre Noll [Wed, 20 Mar 2024 13:43:11 +0000 (14:43 +0100)]
Consult $HOME rather than calling getpwuid(),

Quiting getpwnam(3):

An application that wants to determine its user’s home
directory should inspect the value of HOME (rather than the value
getpwuid(getuid())->pw_dir) since this allows the user to modify
their notion of "the home directory" during a login session.

Change the function to return const char *, i.e. a pointer to the
environment rather than a copy that must be freed by the caller.
Document that the caller must not modify or free this string and fix
all callers accordingly.

6 weeks agoipc: Remove pointless initialization in shm_get_shmmax().
Andre Noll [Wed, 20 Mar 2024 22:32:24 +0000 (23:32 +0100)]
ipc: Remove pointless initialization in shm_get_shmmax().

6 weeks agobuild: Rename all_objs -> dep_objs. next
Andre Noll [Sat, 24 Jun 2023 21:10:09 +0000 (23:10 +0200)]
build: Rename all_objs -> dep_objs.

The old name is misleading since there are additional objects which
correspond to the C files generated by lopsub. Those use different
dependency tracking.

Simplify the code a bit by creating the list in one step.

6 weeks agoserver: Deprecate -l=c and -l=m of com_ls().
Andre Noll [Sun, 17 Mar 2024 14:08:09 +0000 (15:08 +0100)]
server: Deprecate -l=c and -l=m of com_ls().

These are not very useful. The implementation will be removed after
0.8.0.

6 weeks agoNew audio formats: 32 bit float (little and big endian).
Andre Noll [Sat, 8 Sep 2018 10:11:33 +0000 (12:11 +0200)]
New audio formats: 32 bit float (little and big endian).

At least the little endian version seems to be popular these days. It
is only supported by ALSA, however. To check whether a given wave
file employs one of the two SF_FLOAT formats (aka IEEE float) we have
to consult the format code, a 16 bit integer stored at offset 20 of
the wave header which describes the waveform data according to the
table below.

0x0001 PCM
0x0003 IEEE float
0x0006 8-bit ITU-T G.711 A-law
0x0007 8-bit ITU-T G.711 MU-law
0xFFFE Determined by SubFormat

Additional checks are added to check_wav_post_select() which make
sure that the format code is either 1 or 3, and that the number is
compatible with the bits per sample value.

6 weeks agoopenssl: Reactivate openssl warnings.
Andre Noll [Wed, 3 May 2023 22:42:06 +0000 (00:42 +0200)]
openssl: Reactivate openssl warnings.

Now that we use the EVP API for RSA if openssl-3 was detected, the
openssl code no longer calls deprecated functions, so turn back on
the warnings for uses of openssl library functions which are marked
as deprecated.

6 weeks agoopenssl: Use the EVP library for RSA private decryption.
Andre Noll [Mon, 15 May 2023 16:35:30 +0000 (18:35 +0200)]
openssl: Use the EVP library for RSA private decryption.

This is the counterpart of the previous commit which converted the
public RSA encryption. We employ the HAVE_OSSL_PARAM macro again to
distinguish between the openssl-1 and openssl-3 cases.

6 weeks agoopenssl: Use the EVP library for RSA public encryption.
Andre Noll [Sun, 7 May 2023 15:49:58 +0000 (17:49 +0200)]
openssl: Use the EVP library for RSA public encryption.

Many functions related to RSA have been deprecated in openssl-3. Users
of the deprecated API are expected to switch to the high-level
cryptographic functions of the EVP library which ships together
with openssl.

Since openssl-1.0 is still supported and even openssl-1.1 lacks some
of the features we need for EVP, for example OSSL_PARAM_construct_BN(),
we check for this symbol at configure time and use #ifdefs in openssl.c
to compile the code conditionally depending on the value of the new
HAVE_OSSL_PARAM preprocessor macro. The code should work with both
old and new openssl versions.

apc_get_pubkey() used to call RSA_size() to obtain the key size in
bytes for the return value, but RSA_size() is one of the functions
that got deprecated in openssl-3. So modify read_public_key() to
return the number of bits of the modulus (rather than the constant
one), and use 1/8 of this number as the return value.

6 weeks agoapc_priv_decrypt: Let the callee allocate the buffer.
Andre Noll [Sun, 7 May 2023 16:01:43 +0000 (18:01 +0200)]
apc_priv_decrypt: Let the callee allocate the buffer.

This complements the previous commit which made the analogous
change for public encryption. Passing char ** instead of char * to
apc_priv_decrypt() allows us to get rid of the magic 1024 constant
in client_common.c.

6 weeks agoapc_pub_encrypt: Let the callee allocate the buffer.
Andre Noll [Tue, 2 May 2023 21:56:26 +0000 (23:56 +0200)]
apc_pub_encrypt: Let the callee allocate the buffer.

Change the encryption routine of the apc API to allocate a suitably
sized buffer itself. Currently, the caller has to guess the size of the
buffer to pass to the function and we reuse our 4k handshake buffer for
that. While 4k is is plenty at the moment, that may change, and it's
always better to use the exact size if it is readily available. This
is the case here because the required buffer size is just the number
of bits of the modulus of the key.

6 weeks agoopenssl: Assume that openssl allocation functions functions succeed.
Andre Noll [Tue, 2 May 2023 19:52:50 +0000 (21:52 +0200)]
openssl: Assume that openssl allocation functions functions succeed.

We do the same thing with malloc() and friends, so replace error
checking by assertions whenever OOM is the only possible error reason.
Also add assertions for EVP_MD_CTX_new(), whose return value was not
checked at all.

6 weeks agoopenssl: Introduce openssl_perror().
Andre Noll [Tue, 2 May 2023 19:16:29 +0000 (21:16 +0200)]
openssl: Introduce openssl_perror().

Openssl has a decent error reporting framework, but we only employ
it if get_random_bytes_or_die() fails. This patch abstracts out a
new helper which prints the error string of the earliest error code
from the thread's error queue. We make the helper return -E_OPENSSL
unconditionally as this simplifies callers a bit.

Only get_random_bytes_or_die() calls the new helper for now but
additional callers will be added in subsequent commits.

6 weeks agoopenssl: Don't pass pointers to RSA structures around.
Andre Noll [Mon, 1 May 2023 19:43:18 +0000 (21:43 +0200)]
openssl: Don't pass pointers to RSA structures around.

The RSA structure has been made opaque in openssl-3. As a preparation
for not using this structure any more, pass pointers to the containing
asymmetric key structure instead.

6 weeks agoopenssl: Kill rsa coefficient computations.
Andre Noll [Tue, 2 May 2023 17:51:52 +0000 (19:51 +0200)]
openssl: Kill rsa coefficient computations.

There's no need to pre-compute the two exponents for the Chinese
Remainder Theorem calculations as openssl will do that for us.

6 weeks agoclient: Check buffer size returned by apc_priv_decrypt().
Andre Noll [Sun, 7 May 2023 14:40:26 +0000 (16:40 +0200)]
client: Check buffer size returned by apc_priv_decrypt().

The decoded challenge buffer contains the challenge and the two session
keys but nothing else. So we know its size up-front and should fail
the handshake if the size of the rsa-decrypted buffer differs.

6 weeks agoi9e: Clear history on close.
Andre Noll [Wed, 14 Jun 2023 21:15:18 +0000 (23:15 +0200)]
i9e: Clear history on close.

6 weeks agobuild: No longer check for CRYPTO_cleanup_all_ex_data().
Andre Noll [Sat, 24 Jun 2023 20:53:32 +0000 (22:53 +0200)]
build: No longer check for CRYPTO_cleanup_all_ex_data().

Recent openssl versions no longer declare this unless the openssl API
compatibility version is set explicitly, in which case it gets defined
as a macro which does nothing. Either way, the check in configure.ac
and the call in openssl.c can go away.

6 weeks agobuild: Construct list of executables in Makefile.
Andre Noll [Sat, 24 Jun 2023 19:36:17 +0000 (21:36 +0200)]
build: Construct list of executables in Makefile.

This is actually easier and removes some duplication as we currently
have two copies of the logic which decides whether or not to build
each executable. We lose the summary output at the end of the configure
output, but that was incomplete anyway.

6 weeks agobuild: Construct audioc object list in Makefile.
Andre Noll [Sat, 24 Jun 2023 17:34:56 +0000 (19:34 +0200)]
build: Construct audioc object list in Makefile.

This removes the last caller of add_dot_o() in configure.ac, so remove
this function.

6 weeks agobuild: Construct write object list in Makefile.
Andre Noll [Sat, 24 Jun 2023 17:34:21 +0000 (19:34 +0200)]
build: Construct write object list in Makefile.

6 weeks agobuild: Construct play object list in Makefile.
Andre Noll [Sat, 24 Jun 2023 12:35:25 +0000 (14:35 +0200)]
build: Construct play object list in Makefile.

6 weeks agobuild: Construct afh object list in Makefile.
Andre Noll [Sat, 24 Jun 2023 09:02:38 +0000 (11:02 +0200)]
build: Construct afh object list in Makefile.

6 weeks agobuild: Construct filter object list in Makefile.
Andre Noll [Thu, 22 Jun 2023 17:26:10 +0000 (19:26 +0200)]
build: Construct filter object list in Makefile.

6 weeks agobuild: Construct recv object list in Makefile.
Andre Noll [Thu, 22 Jun 2023 17:17:59 +0000 (19:17 +0200)]
build: Construct recv object list in Makefile.

para_recv is always built, which makes the patch comparably small.

6 weeks agobuild: Construct gui object list in Makefile.
Andre Noll [Thu, 22 Jun 2023 15:54:43 +0000 (17:54 +0200)]
build: Construct gui object list in Makefile.

6 weeks agobuild: Construct mixer object list in Makefile.
Andre Noll [Sat, 24 Jun 2023 17:33:26 +0000 (19:33 +0200)]
build: Construct mixer object list in Makefile.

6 weeks agobuild: Construct audiod and client object list in Makefile.
Andre Noll [Sat, 24 Jun 2023 18:03:06 +0000 (20:03 +0200)]
build: Construct audiod and client object list in Makefile.

Both executables are built iff CRYPTOLIB is set, so they can be
handled in one conditional block of Makefile.real.

6 weeks agobuild: Construct server and upgrade_db object list in Makefile.
Andre Noll [Sat, 24 Jun 2023 16:56:05 +0000 (18:56 +0200)]
build: Construct server and upgrade_db object list in Makefile.

Currently configure.ac defines variables for the list of objects of
each executable and exports these via AC_SUBST to Makefile.in. The
lists are then extended and munged further in Makefile.real.

It it easier to construct the lists only in the makefile. So, as
a first step, stop to export the object list of para_server and
para_upgrade_db. Instead, export the variables needed to construct
the list in the makefile.

6 weeks agobuild: Simplify condition for building para_server.
Andre Noll [Sat, 24 Jun 2023 16:56:00 +0000 (18:56 +0200)]
build: Simplify condition for building para_server.

We fail the configure script earlier if flex or bison are not
installed, so we don't need to repeat this check here.

6 weeks agobuild: Simplify ogg helpers of configure.ac.
Andre Noll [Wed, 21 Jun 2023 17:39:23 +0000 (19:39 +0200)]
build: Simplify ogg helpers of configure.ac.

There is no need to define NEED_OGG_OBJECTS and friends as a function
because a simple variable will do as well.

6 weeks agobuild: Remove AUDIOD_AUDIO_FORMATS_ENUM.
Andre Noll [Wed, 21 Jun 2023 21:06:09 +0000 (23:06 +0200)]
build: Remove AUDIOD_AUDIO_FORMATS_ENUM.

No code actually refers to the AUDIO_FORMAT_$FOO values of this
enumeration. Its only purpose is to define the number of supported
audio formats (as the last constant of the enum). We may as well
employ ARRAY_SIZE() for that, so kill the enum and remove the loop
from configure.ac which generates it.

The related audio_formats array, which contains the names of the
supported audio formats, is only used in audiod.c, so we can remove
the declaration from audiod.h and make it static.

6 weeks agobuild: Remove _errlist in shell variables of configure.ac.
Andre Noll [Wed, 21 Jun 2023 16:40:21 +0000 (18:40 +0200)]
build: Remove _errlist in shell variables of configure.ac.

This used to make sense when we had two types of variables per
executable, but those times are long gone.

6 weeks agobuild: yy_src_dir and yy_build_dir can be simply expanded.
Andre Noll [Sat, 24 Jun 2023 19:50:11 +0000 (21:50 +0200)]
build: yy_src_dir and yy_build_dir can be simply expanded.

Simply expanded variables should be preferred whenever possible since
they are more intuitive and a bit faster.

6 weeks agobuild: Remove info about ucred from configure output.
Andre Noll [Wed, 21 Jun 2023 19:21:46 +0000 (21:21 +0200)]
build: Remove info about ucred from configure output.

The $have_ucred variable was removed six years ago, but the stale
summary line remained. Remove it now.

Fixes: 738d19a4cfb194479e9e0c4a474df6b62c57f4b4
6 weeks agobtr: Streamline the documentation of buffer_tree.h.
Andre Noll [Mon, 2 Jan 2023 14:07:31 +0000 (15:07 +0100)]
btr: Streamline the documentation of buffer_tree.h.

Nothing major, just a few minor English issues.

6 weeks agoConstify buffer tree API.
Andre Noll [Mon, 2 Jan 2023 13:43:42 +0000 (14:43 +0100)]
Constify buffer tree API.

A lot of functions of the buffer tree API don't modify the memory
referenced by the pointers passed. This patch marks these pointer
arguments as constant.

6 weeks agobtr: Merge buffers on insertion.
Andre Noll [Fri, 30 Dec 2022 13:09:51 +0000 (14:09 +0100)]
btr: Merge buffers on insertion.

Currently add_btrb_to_children() simply adds the given buffer
reference to the input queue of all children of the given node even
if the newly added buffer reference points memory adjacent to the
previously added buffer.

Since several helpers iterate over all buffer references, performance
suffers, given enough buffer references. So merge buffers when
possible.

User time: 147s -> 83s, speedup: 44%.

6 weeks agobtr: Speed up btr_node_status().
Andre Noll [Fri, 30 Dec 2022 13:09:06 +0000 (14:09 +0100)]
btr: Speed up btr_node_status().

Currently we sum up the sizes of all buffers in the input queue just to
determine if the total size exceeds a small threshold. That's silly
and expensive if there are many buffers. Fix that by introducing
a helper which breaks out of the loop as soon as know the answer
because the threshold is exceeded.

User time: 150s -> 147s, speedup: 2%

6 weeks agoSpeed up mp3dec filter.
Andre Noll [Fri, 30 Dec 2022 13:08:00 +0000 (14:08 +0100)]
Speed up mp3dec filter.

Avoid calling btr_get_input_queue_size() as this is potentially
expensive (depending on the number of chunks in the input queue)
and unnecessary.

The user time of para_play for a ~4m long mp3 file on a very slow
machine went down from 168s to 150s. Speedup: 11%

7 weeks agoparaslash 0.7.3 master v0.7.3
Andre Noll [Tue, 12 Mar 2024 18:02:39 +0000 (19:02 +0100)]
paraslash 0.7.3

7 weeks agoUpdate copyright year.
Andre Noll [Sun, 7 Jan 2024 20:45:52 +0000 (21:45 +0100)]
Update copyright year.

7 weeks agogui: Fix off-by-one in colorful blackness theme.
Andre Noll [Sun, 16 Jul 2023 15:48:22 +0000 (17:48 +0200)]
gui: Fix off-by-one in colorful blackness theme.

Without this, on a 80 character window and the three-digit amp value,
the value gets truncated unnecessarily.

4 months agoaudiod: Improve stat_client_add().
Andre Noll [Tue, 20 Jun 2023 18:49:06 +0000 (20:49 +0200)]
audiod: Improve stat_client_add().

Let it receive a bool rather than an int and dedox its documentation
because it's a static function.

4 months agostring.c: Don't fall back to /tmp in para_homedir().
Andre Noll [Mon, 19 Jun 2023 19:24:29 +0000 (21:24 +0200)]
string.c: Don't fall back to /tmp in para_homedir().

This can only lead to trouble. If we can't get the path to the home
directory, something is deeply wrong and we really should abort.

4 months agocreate_argv_offset(): Use arr_zalloc().
Andre Noll [Mon, 19 Jun 2023 17:56:26 +0000 (19:56 +0200)]
create_argv_offset(): Use arr_zalloc().

There is no point in initializing the allocated array manually,
and it does not hurt to initialize also the last element.

4 months agoCompile with -Wsuggest-attribute=malloc.
Andre Noll [Tue, 30 May 2023 22:11:14 +0000 (00:11 +0200)]
Compile with -Wsuggest-attribute=malloc.

We already employ this attribute extensively to help the compiler
improve optimization. However, a few malloc-like functions were not
yet marked with __malloc. Fix that and enable the warning to make
sure that new malloc-like functions get marked.

Since not all supported compilers know about this warning option, we
need to check at compile time whether the option is supported. Thanks
to the existing cc-option make(1) function, this is a simple one-liner
for Makefile.real.

4 months agoserver: No longer accept "sideband" and "aes_ctr128" features.
Andre Noll [Tue, 9 May 2023 18:02:09 +0000 (20:02 +0200)]
server: No longer accept "sideband" and "aes_ctr128" features.

Both features are used unconditionally since commit d44413588dd7
(v0.6.3-27) from three years ago when the client stopped to request
the feature. We don't need to support clients older than that any more,
so fail the request if these features are still requested.

Clarify the comment about the sha256 feature while at it.

4 months agogui: Clear status bar after pressing <End>.
Andre Noll [Fri, 7 Jul 2023 20:23:45 +0000 (22:23 +0200)]
gui: Clear status bar after pressing <End>.

Without this a stale message such as

"scrolled view: 1-36/42"

remains although the window has been updated to show the bottom of
the ringbuffer.

4 months agoMerge topic branch t/crypt-cleanups into master
Andre Noll [Sun, 24 Dec 2023 15:43:04 +0000 (16:43 +0100)]
Merge topic branch t/crypt-cleanups into master

This bunch of mostry trivial changes can be merged early, before the
openssl code is converted to use the EVP API. The topic was cooking
in next for six months.

* refs/heads/t/crypt-cleanups:
  openssl: Assign bignums in canonical order.
  openssl: Unify naming of public key structures.
  openssl: Rename read_private_rsa_params() -> read_openssh_private_key().
  openssl: Rename read_rsa_bignums() -> read_public_key().
  openssl: Dedox crypt_init().
  server: Improve "loading pubkey" log message.
  gcrypt: Remove pointless state variable.
  client: Reduce line length.

6 months agoMerge topic branch t/ls-L into master
Andre Noll [Sat, 28 Oct 2023 17:20:14 +0000 (19:20 +0200)]
Merge topic branch t/ls-L into master

A single patch which implements the new --limit option for the ls
server command. The confict in aft.c was trivial to fix.

* refs/heads/t/ls-L:
  server: Implement ls --limit.

6 months agoMerge topic branch t/afs-select into master
Andre Noll [Sat, 21 Oct 2023 16:56:48 +0000 (18:56 +0200)]
Merge topic branch t/afs-select into master

A single patch which silences the select command. The merge conflicted
in afs.c, but that was trivial to resolve.

* refs/heads/t/afs-select:
  server: Implement select -verbose.

6 months agoMerge topic branch t/afs-ls-a into master
Andre Noll [Sun, 15 Oct 2023 15:54:41 +0000 (17:54 +0200)]
Merge topic branch t/afs-ls-a into master

A new feature for the ls command. Unfortunately, several bugs were
found after the topic graduated to next, so the series contains a few
fixup commits on top of the single patch which implements the feature.

* refs/heads/t/afs-ls-a:
  afs: Really fix memory leak in mood_load().
  afs: Fix memory leak in mood_load().
  playlist: Fix error handling of playlist_load().
  server: Fix NULL pointer dereference in com_ls().
  Implement ls --admissible=m/foo.

8 months agoMerge topic branch t/fd into master
Andre Noll [Sun, 6 Aug 2023 16:38:05 +0000 (18:38 +0200)]
Merge topic branch t/fd into master

A rash of patches which clean up a good part of fd.c. Nothing major
here, mostly simplifications and documentation improvements.

* refs/heads/t/fd:
  fd: Simplify and move for_each_file_in_dir().
  fd.c: Improve error checking of para_mkdir().
  fd: Revamp para_mkdir().
  fd: Improve read_pattern(), rename it to read_and_compare().
  fd: Remove log message from para_munmap().
  fd: Open-code para_chdir().
  fd: Remove file_exists().
  fd: Improve documentation of xwritev().
  fd: Improve documentation of write_all().
  fd: Improve documentation of write_va_buffer().

9 months agoserver: Fix memory leak at exit.
Andre Noll [Tue, 20 Jun 2023 20:52:07 +0000 (22:52 +0200)]
server: Fix memory leak at exit.

If a playlist is open on exit, we miss to free it. Not a real leak,
but still..

10 months agoafs: Really fix memory leak in mood_load().
Andre Noll [Tue, 20 Jun 2023 21:05:10 +0000 (23:05 +0200)]
afs: Really fix memory leak in mood_load().

The previous fix was insufficient as we also have to destroy the
score table in the success case, so move the freeing to destroy_mood().

Fixes: bb0aec0963b1b2da617aebda26deca576684436c
10 months agoMerge branch 'maint'
Andre Noll [Sun, 18 Jun 2023 13:31:28 +0000 (15:31 +0200)]
Merge branch 'maint'

A single patch which adds a missing error check.

* maint:
  audiod: Fix error checking in init_default_filters().

10 months agoafs: Fix memory leak in mood_load().
Andre Noll [Mon, 12 Jun 2023 23:42:39 +0000 (01:42 +0200)]
afs: Fix memory leak in mood_load().

In the result != NULL case we open a fresh score table but miss to
close it if add_to_score_table() fails. This should never happen,
but still..

Fixes: 2d2637cb4c9ab76fea6bc336b9af88fd00bf5e08
10 months agoplaylist: Fix error handling of playlist_load().
Andre Noll [Mon, 12 Jun 2023 23:14:07 +0000 (01:14 +0200)]
playlist: Fix error handling of playlist_load().

We open a fresh score table if the result pointer is not NULL,
indicating that we are called from com_ls() (with -a=p/foo) rather
than from com_select(). However, if an error occurs afterwards, we
call score_close() unconditionally. This is wrong in the result ==
NULL case (com_select()) because it closes the global score table
which is expected to stay open.

The result is a UAF, which is diagnosed by valgrind as follows:

==4767== Invalid read of size 4
==4767==    at 0x408C51E: osl_add_and_get_row (osl.c:1216)
==4767==    by 0x408CA99: osl_add_row (osl.c:1348)
==4767==    by 0x8060648: score_add (score.c:116)
==4767==    by 0x805F08C: add_to_score_table (mood.c:451)
==4767==    by 0x805FA3E: mood_load (mood.c:650)
==4767==    by 0x8057ECF: activate_mood_or_playlist (afs.c:447)
==4767==    by 0x8059637: com_select_callback (afs.c:1005)

Fixes: 2d2637cb4c9ab76fea6bc336b9af88fd00bf5e08
10 months agoserver: Fix NULL pointer dereference in com_ls().
Andre Noll [Mon, 12 Jun 2023 16:06:10 +0000 (18:06 +0200)]
server: Fix NULL pointer dereference in com_ls().

The previous commit which extended the -a option of the ls command
to accept an optional argument introduced the following flaw: If the
argument of -a corresponds to the name of a mood for which no files
are admissible, the server crashes due to a NULL pointer dereference
because mood_load() leaves the mood instance pointer uninitialized
although it returns zero, indicating success.

This behaviour of mood_load() contradicts the promises made in
its documentation. Fix mood_load() by not special-casing the "zero
admissible files" case, which even simplifies the code a bit. If all
goes well but no files turn out to be admissible, we now open the
score table anyway and set the mood pointer to the allocated mood as
usual. Since get_statistics() may now be called with zero admissible
files, we have to add a check there before dividing by the number of
admissible files,

Fixes: 2d2637cb4c9ab76fea6bc336b9af88fd00bf5e08
10 months agoaudiod_command: Remove dump_stat_client_list().
Andre Noll [Tue, 30 May 2023 20:48:56 +0000 (22:48 +0200)]
audiod_command: Remove dump_stat_client_list().

It is not very useful and can spam the log.

10 months agotest-lib: Write error output to stderr.
Andre Noll [Sun, 7 May 2023 14:16:10 +0000 (16:16 +0200)]
test-lib: Write error output to stderr.

This way one can run

make test > /dev/null

to suppress normal output but still see test failures, if any.

10 months agoserver: Add missing newline in select -v error output.
Andre Noll [Tue, 13 Jun 2023 17:59:56 +0000 (19:59 +0200)]
server: Add missing newline in select -v error output.

The error message that lacks the newline can be triggered by runing
"select -v X".

11 months agoaudiod: Fix error checking in init_default_filters(). maint
Andre Noll [Wed, 17 May 2023 20:13:55 +0000 (22:13 +0200)]
audiod: Fix error checking in init_default_filters().

We ignore the return value of add_filter() instead of assigning it to
ret as usual, then test ret anyway. That's clearly bogus, even more
so since with the old code ret can never be negative at this point, so
the subsequent condition for the subsequent jump to out: is never true.

This bug was introduced 13 years ago.

Fixes: 081ea8699e6a309c44446884b8c3752529d96a25
11 months agoserver: Implement ls --limit.
Andre Noll [Wed, 19 Oct 2022 19:56:51 +0000 (21:56 +0200)]
server: Implement ls --limit.

The new option is quite easy to implement. The patch actually removes
more lines from aft.c than it adds, but this is just because the code
which loops over all matching files was duplicated across the two
branches of the clause which checks whether --reverse was given. The
branches can easily be combined.

11 months agoserver: Implement select -verbose.
Andre Noll [Sat, 22 Oct 2022 19:54:29 +0000 (21:54 +0200)]
server: Implement select -verbose.

Just set ->pbout to NULL if the new option is not given. This supresses
normal output while error messages still make it to the client because
those are sent with afs_error().

11 months agoopenssl: Assign bignums in canonical order.
Andre Noll [Sun, 7 May 2023 15:16:52 +0000 (17:16 +0200)]
openssl: Assign bignums in canonical order.

The order of the bignums stored in the private key is n, e, d, iqmp, p,
q. We read the bignums in this order, so assign the members of the RSA
structure in the same order. This does not really matter, but still..

11 months agoDeprecate openssl-1.0.
Andre Noll [Thu, 4 May 2023 17:09:26 +0000 (19:09 +0200)]
Deprecate openssl-1.0.

These days everybody should have openssl-1.1 (released in 2016)
or later. So warn if configure detects openssl-1.0 or earlier.

11 months agoopenssl: Unify naming of public key structures.
Andre Noll [Tue, 2 May 2023 20:28:56 +0000 (22:28 +0200)]
openssl: Unify naming of public key structures.

The pointers to private key structures are all called "priv", but for
their public counterparts we often use "key" rather than "pub". Fix
that to improve readability.

11 months agoopenssl: Rename read_private_rsa_params() -> read_openssh_private_key().
Andre Noll [Mon, 15 May 2023 16:35:03 +0000 (18:35 +0200)]
openssl: Rename read_private_rsa_params() -> read_openssh_private_key().

The new name encodes the format of the key in the function name just
like the counterpart read_pem_private_key() does.

11 months agoopenssl: Rename read_rsa_bignums() -> read_public_key().
Andre Noll [Sun, 7 May 2023 15:35:50 +0000 (17:35 +0200)]
openssl: Rename read_rsa_bignums() -> read_public_key().

This makes clear that the function is only used for public encryption.

11 months agoopenssl: Dedox crypt_init().
Andre Noll [Wed, 3 May 2023 18:03:18 +0000 (20:03 +0200)]
openssl: Dedox crypt_init().

The API of this function is documented in crypt.h while the comment
in openssl.c describes openssl specific implementation details which
do not need doxygen annotations.

11 months agoserver: Improve "loading pubkey" log message.
Andre Noll [Sun, 30 Apr 2023 14:05:13 +0000 (16:05 +0200)]
server: Improve "loading pubkey" log message.

Include the path to the key file in the output and make the message
more visible by increasing its severity level.

11 months agogcrypt: Remove pointless state variable.
Andre Noll [Tue, 2 May 2023 21:10:49 +0000 (23:10 +0200)]
gcrypt: Remove pointless state variable.

The variable is set but then only used for an unimportant log message.
So let's drop the message and the variable.

11 months agoclient: Reduce line length.
Andre Noll [Sun, 7 May 2023 14:48:58 +0000 (16:48 +0200)]
client: Reduce line length.

Trivial patch, nothing to see here.

11 months agocrypt: Deprecate PEM keys.
Andre Noll [Sat, 29 Apr 2023 21:23:32 +0000 (23:23 +0200)]
crypt: Deprecate PEM keys.

Users have been advised since 2018 to create RFC4716 keys (see
commit 9e2b093bed5d), and this has been the default key format for
ssh-keygen(1) for a long time as well. Upgrade the severity of the
existing log message from info to warning to encourage users at
runtime to replace their old keys.

11 months agoclient: Fix has_feature().
Andre Noll [Tue, 9 May 2023 17:42:21 +0000 (19:42 +0200)]
client: Fix has_feature().

The function returns bool, so a return value of zero is regarded as
false. Consequently, server feature #0 (sha256) is not detected even
if it is announced by the server, and therefore the client does not
request it. Hence both sides fall back to sha1.

This bug was introduced in paraslash-0.7.2.

Fixes: a0707daa23f8706326aa837f969c20d3e4ee02aa
11 months agoafs: Fix memory leak in mood_load().
Andre Noll [Sun, 7 May 2023 18:04:19 +0000 (20:04 +0200)]
afs: Fix memory leak in mood_load().

If mood_load() manages to load the mood but does not find any
admissible files, it does not deallocate the mood instance and does
not set up the global current_mood variable either. Plug the resulting
memory leak by destroying the mood also if there are no admissible
files (ret == 0).

11 months agoImplement ls --admissible=m/foo.
Andre Noll [Wed, 23 Mar 2022 22:19:55 +0000 (23:19 +0100)]
Implement ls --admissible=m/foo.

Currently there can be only one score table at a time because the
functions of score.c refer to the global score_table variable.
To implement the new feature, we need to overcome this restriction
so that the callback of the ls command can populate an independent
score table to print its output without interfering with the score
table that is currently active.

This commit changes most functions of score.c to receive an additional
table pointer argument. All current users of the score table pass a
NULL pointer to instruct the functions to operate on the global score
table as before.

However, if the ls command is invoked with an optional mood argument
to -a. the callback calls mood_load(), followed by mood_loop() and
mood_unload(). The former returns an opaque handle which is then
passed to the other two functions to instruct them to operate on the
temporary score table instead of the global one.

To make the feature work for playlists as well, analogous functionality
is implemented in playlist.c. The new mop_loop() of aft.c performs
the disambiguation in a similar way as the activate_mood_or_playlist()
does. It is a bit simpler though, since the ls command does not have
to deal with NULL arguments and does not need to fall back to the
dummy mood.

11 months agoMerge branch 'maint'
Andre Noll [Thu, 11 May 2023 17:50:22 +0000 (19:50 +0200)]
Merge branch 'maint'

Two fixes for gcc-12 warnings, and another fix for a benign but
embarrassing braino in gcrypt.c.

* maint:
  gcrypt: Fix return value of apc_get_pubkey().
  error.h: Be more careful with error code masking.
  mp3_afh: Drop unused fields from struct mp3header.

11 months agogcrypt: Fix return value of apc_get_pubkey().
Andre Noll [Mon, 8 May 2023 19:25:30 +0000 (21:25 +0200)]
gcrypt: Fix return value of apc_get_pubkey().

The function is supposed to return the key size in bytes, but it
returns the number of *bits*. A consequence of this bug is that
RSA keys which are too short to encrypt our 128 byte buffer are not
rejected as they should be. This is not too serious because we'll fail
later during the encryption step. Fix the bug anyway and clarify the
documentation of apc_get_pubkey().

11 months agoafs: Improve error message in init_admissible_files().
Andre Noll [Sat, 29 Apr 2023 18:08:38 +0000 (20:08 +0200)]
afs: Improve error message in init_admissible_files().

arg may well be NULL here, so print "dummy" in this case.

11 months agotest-lib: Fix typo in comment.
Andre Noll [Sun, 7 May 2023 14:15:12 +0000 (16:15 +0200)]
test-lib: Fix typo in comment.

11 months agoerror.h: Be more careful with error code masking.
Andre Noll [Sat, 6 May 2023 14:49:56 +0000 (16:49 +0200)]
error.h: Be more careful with error code masking.

It should never happen that two or more of the three special high bits
(osl, lopsub, system) are set in an integer that stores a paraslash
error value, but gcc-12 can't prove this and complains as follows:

error.h:304:28: warning: array subscript 268435456 is above array bounds of 'const char * const[220]' [-Warray-bounds]
  304 |         return para_errlist[num];
      |                ~~~~~~~~~~~~^~~~~

Avoid this warning by always clearing all three special bits.