mirror of
https://git.rwth-aachen.de/acs/public/villas/node/
synced 2025-03-09 00:00:00 +01:00
fix possible NULL dereferencing in villasfpga_dma.c
Signed-off-by: Niklas Eiling <niklas.eiling@eonerc.rwth-aachen.de>
This commit is contained in:
parent
1d9ccd6c05
commit
d9993409e0
5 changed files with 9 additions and 6 deletions
|
@ -12,7 +12,7 @@ set(SOURCES
|
|||
core.cpp
|
||||
node.cpp
|
||||
utils.cpp
|
||||
villasfpga_dma.cpp
|
||||
dma.cpp
|
||||
|
||||
ips/aurora_xilinx.cpp
|
||||
ips/aurora.cpp
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* SPDX-License-Identifier: Apache-2.0
|
||||
*********************************************************************************/
|
||||
|
||||
#include <villas/fpga/villasfpga_dma.h>
|
||||
#include <villas/fpga/dma.h>
|
||||
|
||||
#include <csignal>
|
||||
#include <iostream>
|
|
@ -37,7 +37,7 @@ target_link_libraries(unit-tests-fpga PUBLIC
|
|||
${CRITERION_LIBRARIES}
|
||||
)
|
||||
|
||||
add_executable(villasfpga-dma villasfpga_dma.c)
|
||||
add_executable(villasfpga-dma dma.c)
|
||||
|
||||
target_include_directories(villasfpga-dma PUBLIC
|
||||
../include
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include <villas/fpga/villasfpga_dma.h>
|
||||
#include <villas/fpga/dma.h>
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
|
@ -21,7 +21,10 @@ int main(int argc, char *argv[])
|
|||
float f;
|
||||
size_t size;
|
||||
|
||||
if (argc != 2 && argv != NULL) {
|
||||
if (argv == NULL) {
|
||||
return 1;
|
||||
}
|
||||
if (argc != 2 || argv[1] == NULL) {
|
||||
fprintf(stderr, "Usage: %s <config file>\n", argv[0]);
|
||||
}
|
||||
|
||||
|
@ -66,7 +69,7 @@ int main(int argc, char *argv[])
|
|||
}
|
||||
|
||||
printf("Enter a float:\n");
|
||||
if ((ret = scanf("%f", mem2ptr)) != 1) {
|
||||
if ((ret = scanf("%f", (float*)mem2ptr)) != 1) {
|
||||
fprintf(stderr, "Failed to parse input: sscanf returned %d\n", ret);
|
||||
ret = 1;
|
||||
goto out;
|
Loading…
Add table
Reference in a new issue