Commit graph

127 commits

Author SHA1 Message Date
David Christle
faefdac4ab
fix(rotctl): bound escaped command parsing
Stop parsing when an escape is missing or consumes no input, and count only successfully decoded bytes. This avoids the extra strtol call beyond the command terminator while preserving valid raw commands.
2026-07-29 10:39:38 -05:00
David Christle
c0adbb27bb
fix(ctl): bound command parser inputs
Reject stream read errors instead of synthesizing empty commands, validate raw hexadecimal command syntax without reading past its terminator, and keep fixed-size command and description inputs within their actual capacities.
2026-07-27 23:32:48 -05:00
George Baltz N3GB
0508a165c5 Shrink scope of some iteration variables 2026-06-23 12:13:22 -04:00
George Baltz N3GB
7df5ae1a00 Fix errors found by glibc 2.43
glibc implements some new parts of the C23 standard:
(Taken from https://download.opensuse.org/tumbleweed/iso/Changes.20260430.txt)

  * For ISO C23, the functions bsearch, memchr, strchr, strpbrk, strrchr,
    strstr, wcschr, wcspbrk, wcsrchr, wcsstr and wmemchr that return
    pointers into their input arrays now have definitions as macros that
    return a pointer to a const-qualified type when the input argument is
    a pointer to a const-qualified type

and

  * The aforementioned change in ISO C23 of the declaration of bsearch,
    memchr, strchr, strpbrk, strrchr, strstr, wcschr, wcspbrk, wcsrchr,
    wcsstr, and wmemchr as const-preserving macros can lead to compilation
    issues in code not set up for it

This lead to some warnings about assigning returns from strchr(const, target)
  to non-const pointers, and then discovering that Hamlib was modifying
  those const parameters.

This commit aligns the const-ness of the offending parameters. Only affects
  internal functions in ampctl_parse.c, rigctl_parse.c and rotctl_parse.c,
  so API/ABI should not change.
2026-05-03 14:55:05 -04:00
George Baltz N3GB
29c4ec4778 Finish adding #include's for things moving out of rig.h
Clean compile & execution with both NO_OLD_INCLUDES and NO_OLD_STRUCTS
  defined.
2026-02-23 11:12:15 -05:00
George Baltz N3GB
02ea4af572 Move rig_state to heap storage.
Allocate and free it.
For access apps must
1) #include <hamlib/rig_state.h>  and
2) Use HAMLIB_STATE(rig) to get the address

Also fix a couple of misuses of STATE() macro.
2026-02-23 11:02:34 -05:00
George Baltz N3GB
de5087f57a Same for ampctl_parse.c
Update NEWS
Fix compiler snit about possible truncation
2026-01-28 04:50:19 -05:00
George Baltz N3GB
330b791216 Fix string overflows in rotctl_parse.c 2026-01-27 22:25:43 -05:00
Daniele Forsi IU5HKX
ee42a8c120 Fix typos 2025-12-21 13:12:23 +01:00
Daniele Forsi IU5HKX
19ce6d30b0 Put get_conf near set_conf 2025-10-04 22:37:09 +02:00
Nate Bargmann
f15537f2e6
Merge GitHub PR #1875 2025-09-02 15:38:54 -05:00
Daniele Forsi IU5HKX
e4c43821d0 Always print error messages to stderr
Do not depend on the debug level set with --verbose
2025-09-02 21:54:18 +02:00
Daniele Forsi IU5HKX
632746cf91 Use rig_debug() instead of sending error messages to stdout 2025-08-30 16:20:32 +02:00
George Baltz N3GB
002677e48c Still more pthread conditional code cleanup 2025-08-27 15:24:50 -04:00
Daniele Forsi IU5HKX
0317e64dc8 Remove double call to rig_token_lookup() and rot_token_lookup()
The needed value is already in the variable.

Test case /to check that the changes don't break the code):
tests/rigctl --set-conf=rig_pathname=test,write_delay=1,timeout=2 --show-conf Q | grep --no-group-separator -A1 -E "(rig_pathname|^write_delay|^timeout):"
tests/rotctl --set-conf=rot_pathname=test,write_delay=1,timeout=2 --show-conf Q | grep --no-group-separator -A1 -E "(rot_pathname|^write_delay|^timeout):"

The output before and after this patch is:
rig_pathname: "Path name to the device file of the rig"
        Default: /dev/rig, Value: test
write_delay: "Delay in ms between each byte sent out"
        Default: 0, Value: 1
timeout: "Timeout in ms"
        Default: 0, Value: 2
Command 'Q' not found!
rot_pathname: "Path name to the device file of the rotator"
        Default: /dev/rotator, Value: test
write_delay: "Delay in ms between each byte sent out"
        Default: 0, Value: 1
timeout: "Timeout in ms"
        Default: 0, Value: 2
2025-08-20 23:07:48 +02:00
Daniele Forsi IU5HKX
a0fa2def82 Refactor to remove code duplication in rotctl*.c 2025-08-19 16:51:31 +02:00
Daniele Forsi IU5HKX
caf7346fc0 Fix typos 2025-08-16 11:52:55 +02:00
Daniele Forsi IU5HKX
2a2f33673e Handle the question mark as second argument of set_level in rotctl
Test command:

tests/rotctl -m 1 \
set_level MGC '?' \
set_level MGF '?' \
set_level MGL '?' \
set_level SPEED '?'
2025-08-12 20:38:53 +02:00
George Baltz N3GB
72bc62366d A few more cppcheck messages silenced 2025-07-28 19:31:20 -04:00
George Baltz N3GB
faad247f06 Deprecate rot_get_conf() 2025-07-28 10:43:10 -04:00
Daniele Forsi IU5HKX
0267068220 Fix ambiguity between system includes and Hamlib includes 2025-07-22 23:33:57 +02:00
Daniele Forsi IU5HKX
2fab137fc5 Apply fixes suggested by iwyu
Removes unused includes and adds missing includes.
2025-07-22 23:33:57 +02:00
George Baltz N3GB
07d0d91a44 Yet more cppcheck messages silenced. 2025-06-15 13:52:09 -04:00
Nate Bargmann
bddd3ace00
Revert 17b404a6c7
These changes were unnecessary as the real bug is that the incorrect
function was being called in meade.c.

Closes GitHub issue #268.

Fix testloc.c
2025-06-14 11:42:45 -05:00
Daniele Forsi IU5HKX
10180a6dc2 Fix sign of error return values
All RIG_E* constants should be negated when returned or compared.

Fixed with:
perl -pe 's/return RIG_E/return -RIG_E/' -i $(grep -lEr "return RIG_E" --include=*.{c,h})
perl -pe 's/= RIG_E/= -RIG_E/g' -i $(grep -lEr "= RIG_E" --include=*.{c,h})
2025-06-07 12:07:44 +02:00
Michael Black W9MDB
b763761d9e Fix cleartext warning in rigctl_parse.c and rotctl_parse.c 2024-12-22 11:26:18 -06:00
Mike Black W9MDB
5c269964c2 astyle files in preparation for release 4.6 2024-11-06 08:07:34 -06:00
George Baltz N3GB
7bf63ecbf0 More amplifier and rotator state changes 2024-07-14 01:17:28 -04:00
Mike Black W9MDB
745e72a6cf Add
ROT_MOVE_UP_LEFT, ROT_MOVE_UP_CCW
ROT_MOVE_UP_RIGHT, ROT_MOVE_UP_CW
ROT_MOVE_DOWN_LEFT, ROT_MOVE_DOWN_CCW
ROT_MOVE_DOWN_RIGHT, ROT_MOVE_DOWN_CW
Supported by SPID rotators
2024-05-30 17:34:02 -05:00
George Baltz N3GB
07f8023d17 Convert tests/* to pointers 2024-03-01 12:27:26 -05:00
Mike Black W9MDB
05033171c3 Change token_t to hamlib_token_t to avoid collsions with libbsm and others
https://github.com/Hamlib/Hamlib/issues/1469
2024-01-21 23:11:55 -06:00
Mikael Nousiainen
051e671bfa Merge upstream changes and fix conflicts. Use snprintf() in most sprintflst.c functions to avoid buffer overflows. 2024-01-04 10:43:15 +02:00
Mike Black W9MDB
576ed8266a Ignore scanfc Invalid argument for rotctld
https://github.com/Hamlib/Hamlib/issues/1391
2023-12-19 16:23:03 -06:00
Mike Black W9MDB
e267c62764 astyle files 2023-12-16 11:37:58 -06:00
Mike Black W9MDB
02ffc6d6dc More set_conf/get_conf work
https://github.com/Hamlib/Hamlib/issues/971
2023-11-05 17:03:21 -06:00
Mike Black W9MDB
914c4f4d2a Add clearerr in rotctl_parse.c 2023-10-18 16:45:42 -05:00
Mike Black W9MDB
8d15c04727 Fix more cppcheck items 2023-10-14 12:01:41 -05:00
Mike Black W9MDB
d72127f29a Fix cppcheck warnings 2023-10-11 23:22:42 -05:00
Mike Black W9MDB
d5f7660781 Fix some more cppcheck items
https://github.com/Hamlib/Hamlib/issues/1351
2023-10-06 15:14:10 -05:00
Mike Black W9MDB
1a4a189dbc Try to make rigctl(d)/rotctl(d) a little more robust in case of bad data
https://github.com/Hamlib/Hamlib/issues/1351
2023-10-02 10:48:26 -05:00
Mike Black W9MDB
2da6c400f7 Add RTS/DTR capability to rotctl and ampctl 2023-07-20 11:58:26 -05:00
Daniele Forsi IU5HKX
1c72440c51 Fix segfaults with malformed input and wrong command line arguments
Fixes:
NULL dereference.

Steps to reproduce:
echo L x | tests/ampctl
echo L x | tests/rigctl
echo L x | tests/rotctl
2023-04-10 19:44:49 +02:00
Daniele Forsi IU5HKX
e11b4bd01c Fix segfaults with malformed input and wrong command line arguments
Fixes:
NULL dereference.

Steps to reproduce:
echo L | tests/ampctl
echo L | tests/rigctl
echo L | tests/rotctl
2023-04-10 19:44:40 +02:00
Daniele Forsi IU5HKX
3f90086991 [tests] Fix includes 2023-02-16 19:08:24 +01:00
Mike Black W9MDB
6c5e0e6974 Update astyle formatting 2022-11-16 15:30:36 -06:00
Mike Black W9MDB
d7ab039573 Fix backwards compatibility of rotctl with rotctld
https://github.com/Hamlib/Hamlib/issues/1035
2022-11-10 22:28:28 -06:00
Mike Black W9MDB
782e54e4f2 Fix new protocol in rotctl functions to duplicate logic in rigctl new protocol
https://github.com/Hamlib/Hamlib/issues/1035
2022-11-10 21:54:00 -06:00
Mike Black W9MDB
853806b978 Fix rotctld dumpcaps to expose client rot_type instead of Other
https://github.com/Hamlib/Hamlib/issues/1035
2022-11-10 17:53:21 -06:00
Mike Black W9MDB
a83eb3bf42 astyle files for 4.5 release 2022-07-27 17:16:17 -05:00
Mike Black W9MDB
627ec83652 Change malloc to calloc 2022-07-27 10:26:08 -05:00