Project

General

Profile

Bug #5008

Quoted whitespace parsing problem in source_impl::source_impl

Added by WGH about 1 month ago.

Status:
New
Priority:
Normal
Assignee:
-
Target version:
-
Start date:
02/04/2021
Due date:
% Done:

0%

Spec Reference:

Description

source_impl::source_impl has the following code fragment (for clarity, non-relevant pieces are omitted):


source_impl::source_impl( const std::string &args ) {
    std::vector< std::string > arg_list = args_to_vector(args);
    for (std::string arg : arg_list) {
        dict_t dict = params_to_dict(arg);
        if ( dict.count("soapy") ) { 
            soapy_source_c_sptr src = make_soapy_source_c( arg );
            block = src; iface = src.get();
        }
    }
}

The problem is that if args contains properly quoted whitespaces, the quoting is lost, and it causes problems later on.

(gdb) p args
$13 = "device='HackRF One',driver=remote,part_id=a000cb3c00474757,remote=tcp://192.168.0.102:55132,remote:driver=hackrf,serial=", '0' <repeats 16 times>, "909864c8337b58cf,soapy=0,version=2018.01.1" 
(gdb) p arg_list
$14 = std::vector of length 1, capacity 1 = {"device=HackRF One,driver=remote,part_id=a000cb3c00474757,remote=tcp://192.168.0.102:55132,remote:driver=hackrf,serial=", '0' <repeats 16 times>, "909864c8337b58cf,soapy=0,version=2018.01.1"}

The string without quotes is passed to make_soapy_source_c:


soapy_source_c::soapy_source_c (const std::string &args) {
    _nchan = std::max(1, args_to_io_signature(args)->max_streams());
}

args_to_io_signature splits the string again, incorrectly: args_to_vector("device=HackRF One") would be {"device=HackRF", " One"}. The function calculates the nchan value as 2, and it causes SoapySDR HackRF driver to fail here: https://github.com/pothosware/SoapyHackRF/blob/7d530872f96c1cbe0ed62617c32c48ce7e103e1d/HackRF_Streaming.cpp#L162-L165

This problem can be observed in gqrx. The automatically detected device string will contain quoted string with whitespaces, and it will fail with error message "setupStream invalid channel selection". As a workaround, one can manually remove the whitespaces, and it will work.

The issue appears as of v0.2.3. I haven't actually checked master, but there seems to be no relevant commits fixing the issue.

Also available in: Atom PDF

Add picture from clipboard (Maximum size: 48.8 MB)