Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix sprintf usage in format json functions #293

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

Arpenaige
Copy link

@Arpenaige Arpenaige commented Mar 3, 2024

hostnamectl

Operating System: Ubuntu 23.10
Kernel: Linux 6.5.0-17-generic
Architecture: x86-64

lib version

-- Found PkgConfig: /usr/bin/pkg-config (found version "1.8.1")
-- Checking for module 'fftw3f'
--   Found fftw3f, version 3.3.10
-- Checking for module 'alsa'
--   Found alsa, version 1.2.9
-- Checking for module 'libconfig'
--   Found libconfig, version 1.5
-- Checking for module 'libpulse-simple'
--   Found libpulse-simple, version 16.1

After i build odas and start, i see that *.json files only contain "}" strings(2251 in my case) like this

}
}
}
}
}
}

How i build ODAS

cd

# Before next apt-get's i added to the end of file "/etc/apt/sources.list" this line
# >deb http://cz.archive.ubuntu.com/ubuntu lunar main universe

sudo apt-get update
sudo apt-get install libfftw3-dev libconfig-dev libasound2-dev libgconf-2-4
sudo apt-get install cmake
sudo apt-get install -y build-essential libpulse-dev git

git clone https://github.com/introlab/odas.git

mkdir odas/build
cd odas/build

cmake ..
make

What exactly is the problem and why should you not do that ?

sprintf(buff, “%s %s”, buff, “some text”); - incorrect usage

https://stackoverflow.com/questions/1973572/can-the-input-and-output-strings-to-sprintf-be-the-same

https://stackoverflow.com/questions/21912061/strange-output-of-sprintf-whats-causing-it

opengroup

https://pvs-studio.com/en/docs/warnings/v541/

Files and functions affected

odas/src/sink/snk_pots.c:snk_pots_process_format_text_json

odas/src/sink/snk_tracks.c:snk_tracks_process_format_text_json

odas/src/sink/snk_categories.c:snk_categories_process_format_text_json

After commit

Tested with config on three json variants - everything works fine:

ssl:
potential: {
    format = "json";

    interface: {
        type = "file";
        path = "ssl.potenital.json";
    };
};

sst:
tracked: {
    format = "json";

    interface: {
        type = "file";
        path = "sst.tracked.json";
    };
};

classify:
category: {
    format = "json";

    interface: {
        type = "file";
        path = "classify.category.json"
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant