Commit graph

460 commits

Author SHA1 Message Date
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
Nate Bargmann
55366e14f2
Merge commit from fork
For your consideration
2026-06-12 08:59:45 -05:00
George Baltz N3GB
a3a7f00d75 Bend boundary->subscript conversion in the right direction.
Don't mess with binary data.
2026-06-06 10:02:26 -04:00
George Baltz N3GB
11dbace230 Make a padded copy of input so compare doesn't overread
Cleanup:
Fix typo and formatting
Move RIGCTLD_PASSWORDS from rig.h to rigctl_parse.h
2026-06-05 04:37:50 -04:00
George Baltz N3GB
cef2d9d3a9 Move password status to connection specific data.
Fix memory leak in rigctld_password_check()
2026-06-03 16:52:49 -04:00
George Baltz N3GB
b56f8d8f8a Infrastructure and setup for associating connection data with thread
Will allow rigctl_parse() routines access to connection data, without
  reworking all of the internal and external interfaces.
2026-06-03 15:45:12 -04:00
George Baltz N3GB
7fc1389349 Turn off passwords and their help text
Disable them until they work
2026-06-03 13:07:07 -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
b6a25c8a83 Avoid warnings from gcc-16
gcc-16 adds warnings about using strncpy() to copy into a buffer with
  size equal to the max count, possibly creating an unterminated string.
  Since we don't care about the contents here and both buffers are the
  same size, just do a byte copy.
2026-03-13 05:21:54 -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
f6734ad832 Add the missing commit
Plus a few more arbitrary lengths, so `git grep scanfc` shows no more
  bare "%s" format strings.
2026-01-28 15:44:36 -05:00
George Baltz N3GB
9d40f9f180 Fix unbounded scanf string in rigctl_parse.c
Thanks to Vlatko Kosturjak with Marlink Cyber, for reporting it.
2026-01-27 22:25:43 -05:00
Daniele Forsi IU5HKX
ee42a8c120 Fix typos 2025-12-21 13:12:23 +01:00
George Baltz N3GB
08a013b87b Fix memory leak in rigctld
Just started playing with valgrind, and already We have a Winner!
rigctld was leaking ~100 bytes every 5 seconds; rearrange code so
  arg is not allocated until it is needed and will be passed to the
  routine that will free() it.
Also fix uninitialized variable warning.
2025-12-10 16:16:02 -05:00
Daniele Forsi IU5HKX
bceb1a1fdf Do not use abbreviations where there is enough space 2025-10-05 11:36:03 +02:00
Daniele Forsi IU5HKX
486ec607dd Remove space for consistency with other descriptions 2025-10-05 11:31:10 +02:00
Daniele Forsi IU5HKX
a7188c201a Put set_gpio before get_gpio
Like other set/get pairs.
2025-10-05 09:02:00 +02:00
Daniele Forsi IU5HKX
0546e764af Update comments
All letters are used now, rig_set/rig_get are added and -W is
reserved by POSIX.2 for implementation extensions of get_opt,
but it doesn't apply here because this code is using strcmp()
and the W command which is implemented is not prefixed by a '-'.
2025-10-05 00:29:01 +02:00
Daniele Forsi IU5HKX
6238a5ef1b Reorder commands in --help output
Puts more related get/set commands side by side in the columnar output.
2025-10-04 21:51:00 +02:00
Daniele Forsi IU5HKX
c0717e7834 Remove duplicated command from --help output 2025-10-04 21:30:36 +02:00
Daniele Forsi IU5HKX
b1a673326b Wrap wide columns with the list of commands 2025-09-22 23:53:33 +02:00
Daniele Forsi IU5HKX
ca638238cb Wrap longer commands in the help text 2025-09-22 22:57:08 +02:00
Daniele Forsi IU5HKX
901682ba30 [rigctl] Use "fout" for consistency
This makes no difference in the current code, but other usages
of dumpconf_list() are different:
$ grep dumpconf_list *parse.c
rigctl_parse.c:        dumpconf_list(rig, stdout);
rigctl_parse.c:        dumpconf_list(rig, fout);
rotctl_parse.c:        dumpconf_list(rot, fout);
rotctl_parse.c:        dumpconf_list(rot, fout);
rotctl_parse.c:    dumpconf_list(rot, fout);
2025-09-03 20:32:09 +02: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
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
Nate Bargmann
db7219b731
Merge GitHub PR #1858 2025-08-19 20:05:20 -05:00
Daniele Forsi IU5HKX
67038154db Refactor to remove code duplication in rigctl*.c 2025-08-19 16:51:31 +02:00
Daniele Forsi IU5HKX
fd7d69d24c Fix output of dump_state
Fixes references to levels and properly handles strings.

Steps to reproduce:
tests/rigctl chk_vfo dump_state
2025-08-17 18:49:52 +02:00
Daniele Forsi IU5HKX
2f2b703ccf Handle the question mark as second argument of set_parm KEYERTYPE in rigctl
Test case:
tests/rigctl -m 1 \
set_parm KEYERTYPE '?' \
set_parm BANDSELECT '?'
STRAIGHT BUG PADDLE
BANDUNUSED BAND70CM BAND33CM BAND23CM
2025-08-13 22:04:15 +02:00
Daniele Forsi IU5HKX
b5b9e136a1 Do not use strcmp() when we are going to get a RIG_PARM_* define anyway 2025-08-13 20:24:22 +02:00
Daniele Forsi IU5HKX
fb4d2c6455 Fix segfault when using the dummy driver
Steps to reproduce:
tests/rigctl -m 1 \
get_parm KEYERTYPE

Fixes:
 Thread 1 "rigctl" received signal SIGSEGV, Segmentation fault.
 0x0000556aff4f890d in rigctl_get_parm (rig=<optimized out>, fout=0x7f87517f25c0 <_IO_2_1_stdout_>, fin=<optimized out>, interactive=1, prompt=1, vfo_opt=<optimized out>, send_cmd_term=13 '\r', ext_resp=0, resp_sep=10 '\n',
     cmd=0x556aff516050 <test_list+1520>, vfo=536870912, arg1=0x7ffc5985b5c0 "KEYERTYPE", arg2=0x556aff50cce8 "", arg3=0x556aff50cce8 "") at rigctl_parse.c:3947
 3947            if (strcmp(val.s, "0") == 0) {s = "STRAIGHT";}
 (gdb) bt
 #0  0x0000556aff4f890d in rigctl_get_parm (rig=<optimized out>, fout=0x7f87517f25c0 <_IO_2_1_stdout_>, fin=<optimized out>, interactive=1, prompt=1, vfo_opt=<optimized out>, send_cmd_term=13 '\r', ext_resp=0, resp_sep=10 '\n',
     cmd=0x556aff516050 <test_list+1520>, vfo=536870912, arg1=0x7ffc5985b5c0 "KEYERTYPE", arg2=0x556aff50cce8 "", arg3=0x556aff50cce8 "") at rigctl_parse.c:3947
 #1  0x0000556aff5007f6 in rigctl_parse (my_rig=<optimized out>, fin=<optimized out>, fout=<optimized out>, argv=argv@entry=0x7ffc5985d788, argc=argc@entry=3, sync_cb=sync_cb@entry=0x0, interactive=<optimized out>, prompt=<optimized out>,
     vfo_opt=<optimized out>, send_cmd_term=<optimized out>, ext_resp_ptr=<optimized out>, resp_sep_ptr=<optimized out>, use_password=<optimized out>) at rigctl_parse.c:1847
 #2  0x0000556aff4eaadc in main (argc=<optimized out>, argv=0x7ffc5985d788) at rigctl.c:801
2025-08-13 20:23:57 +02:00
Daniele Forsi IU5HKX
3013912111 Make get_param read back the value passed to set_param
Test case:
tests/rigctl -m 1 \
set_parm KEYERTYPE BUG get_parm KEYERTYPE \
set_parm KEYERTYPE PADDLE get_parm KEYERTYPE \
set_parm KEYERTYPE STRAIGHT get_parm KEYERTYPE
BUG
PADDLE
STRAIGHT
2025-08-13 20:17:56 +02:00
Daniele Forsi IU5HKX
12ba558343 Fix segfault with set_parm KEYERTYPE
Steps to reproduce:
tests/rigctl -m 1 \
set_parm KEYERTYPE BUG

Fixes:
 Thread 1 "rigctl" received signal SIGSEGV, Segmentation fault.
 __strlen_sse2 () at ../sysdeps/x86_64/multiarch/strlen-sse2.S:142
 warning: 142    ../sysdeps/x86_64/multiarch/strlen-sse2.S: File o directory non esistente
 (gdb) bt
 #0  __strlen_sse2 () at ../sysdeps/x86_64/multiarch/strlen-sse2.S:142
 #1  0x00007ffac346e300 in __printf_buffer (buf=buf@entry=0x7ffc3bcf40d0, format=0x7ffac38aef17 "%s", ap=0x7ffc3bcf4190, mode_flags=0) at ./stdio-common/vfprintf-process-arg.c:435
 #2  0x00007ffac3491daf in __vsnprintf_internal (string=<optimized out>, maxlen=<optimized out>, format=<optimized out>, args=args@entry=0x7ffc3bcf4190, mode_flags=mode_flags@entry=0) at ./libio/vsnprintf.c:96
 #3  0x00007ffac3469642 in __GI___snprintf (s=s@entry=0x7ffc3bcf4290 "", maxlen=maxlen@entry=32, format=format@entry=0x7ffac38aef17 "%s") at ./stdio-common/snprintf.c:31
 #4  0x00007ffac370b7b9 in dummy_set_parm (rig=0x558fe1991b20, parm=2048, val=...) at dummy.c:1704
 #5  0x0000558fb536afbe in rigctl_set_parm (rig=0x558fe1991b20, fout=0x7ffac35f25c0 <_IO_2_1_stdout_>, fin=<optimized out>, interactive=<optimized out>, prompt=<optimized out>, vfo_opt=<optimized out>, send_cmd_term=13 '\r', ext_resp=0,
     resp_sep=10 '\n', cmd=0x558fb5388000 <test_list+1440>, vfo=536870912, arg1=0x7ffc3bcf4e10 "KEYERTYPE", arg2=0x558fb537fdb1 "1", arg3=0x558fb537ece8 "") at rigctl_parse.c:3829
 #6  0x0000558fb53727d6 in rigctl_parse (my_rig=<optimized out>, fin=<optimized out>, fout=<optimized out>, argv=argv@entry=0x7ffc3bcf6fd8, argc=argc@entry=3, sync_cb=sync_cb@entry=0x0, interactive=<optimized out>, prompt=<optimized out>,
     vfo_opt=<optimized out>, send_cmd_term=<optimized out>, ext_resp_ptr=<optimized out>, resp_sep_ptr=<optimized out>, use_password=<optimized out>) at rigctl_parse.c:1847
 #7  0x0000558fb535cadc in main (argc=<optimized out>, argv=0x7ffc3bcf6fd8) at rigctl.c:801
2025-08-13 17:07:55 +02:00
Daniele Forsi IU5HKX
a81aab6e11 Return an error if the keyer type is unknown
Instead of quietly doing nothing.
2025-08-13 16:58:46 +02:00
Daniele Forsi IU5HKX
762caa85c0 Remove stray char after printing value of KEYERTYPE
Steps to reproduce:
tests/rigctl -m 1 get_parm KEYERTYPE
STRAIGHT
v <-- this 'v' shouldn't be there
2025-08-13 16:58:46 +02:00
Daniele Forsi IU5HKX
4187e9f4a3 Handle the question mark as second argument of set_level in rigctl
Closes #720.

Test command:

tests/rigctl -m 1 \
set_level AF '?' set_level AGC '?' set_level AGC_TIME '?' \
set_level ANTIVOX '?' set_level APF '?' set_level ATT '?' \
set_level BAL '?' set_level BAND_SELECT '?' set_level BKINDL '?' \
set_level BKIN_DLYMS '?' set_level COMP '?' set_level CWPITCH '?' \
set_level IF '?' set_level KEYSPD '?' set_level METER '?' \
set_level MGC '?' set_level MGF '?' set_level MGL '?' \
set_level MICGAIN '?' set_level MONITOR_GAIN '?' set_level NB '?' \
set_level NOTCHF '?' set_level NOTCHF_RAW '?' set_level NR '?' \
set_level PBT_IN '?' set_level PBT_OUT '?' set_level PREAMP '?' \
set_level RF '?' set_level RFPOWER '?' set_level SLOPE_HIGH '?' \
set_level SLOPE_LOW '?' set_level SPECTRUM_ATT '?' set_level SPECTRUM_AVG '?' \
set_level SPECTRUM_EDGE_HIGH '?' set_level SPECTRUM_EDGE_LOW '?' set_level SPECTRUM_MODE '?' \
set_level SPECTRUM_REF '?' set_level SPECTRUM_SPAN '?' set_level SPECTRUM_SPEED '?' \
set_level SQL '?' set_level USB_AF '?' set_level USB_AF_INPUT '?' \
set_level VOXDELAY '?' set_level VOXGAIN '?'
2025-08-12 20:38:11 +02:00
George Baltz N3GB
20eeb96787 Deprecate rig_get_conf()
Define macro to set attribute, if compiler is capable
Add macro to rig_get_conf(), Rig::getConf() declarations
Fix internal uses of rig_get_conf()
2025-07-27 11:31:18 -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
0740af61a3 Fix memory leak in rigctl_parse.c
strip_quotes() orphaned 1 or 2 strings per call.
2025-06-21 04:39:11 -04:00
George Baltz N3GB
07d0d91a44 Yet more cppcheck messages silenced. 2025-06-15 13:52:09 -04:00
Daniele Forsi IU5HKX
4109d606b5 Fix typos 2025-05-22 21:55:10 +02:00
Michael Black W9MDB
f2a9f091d0 Change rig_list_foreach back to using const argument -- was breaking many C++ application builds
https://github.com/Hamlib/Hamlib/issues/1647
2024-12-29 08:42:24 -06:00
Michael Black W9MDB
8edf99fc18 Change skipinit so skip-init for consistency
And now ignores the skip-init on the non-interactive rigctl
2024-12-25 16:36:37 -06:00
Michael Black W9MDB
750adb40b5 Fix cleartext warning in rigctl_parse.c 2024-12-22 11:30:04 -06:00
Michael Black W9MDB
b763761d9e Fix cleartext warning in rigctl_parse.c and rotctl_parse.c 2024-12-22 11:26:18 -06:00
Michael Black W9MDB
d302b8fabd Fix sscanf in rigctl_parse.c 2024-12-22 11:14:14 -06:00
Michael Black W9MDB
fe45fa2dfc Fix sscanf compare in rigctl_parse.c 2024-12-22 10:38:07 -06:00