view loadtools/secondprog.c @ 1011:6d9b10633f10 default tip

etmsync Pirelli IMEI retrieval: fix poor use of printf() Bug reported by Vadim Yanitskiy <fixeria@osmocom.org>: the construct where a static-allocated string was passed to printf() without any format arguments causes newer compilers to report a security problem. Given that formatted output is not needed here, just fixed string output, change printf() to fputs(), and direct the error message to stderr while at it.
author Mychaela Falconia <falcon@freecalypso.org>
date Thu, 23 May 2024 17:29:57 +0000
parents 064d4eedb3a6
children
line wrap: on
line source

/*
 * This module contains the code for passing the serial channel to a
 * second program, used by fc-iram and fc-xram.
 */

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

extern char **passon_argv;
extern int passon_argc;

exec_2nd_prog()
{
	char **execp_argv;
	char **sp, **dp;
	extern int target_fd;
	char desc_arg[16];

	sprintf(desc_arg, "-d%d", target_fd);
	execp_argv = (char **) malloc(sizeof(char *) * (passon_argc + 2));
	if (!execp_argv) {
		perror("malloc argv for execvp");
		exit(1);
	}
	sp = passon_argv;
	dp = execp_argv;
	*dp++ = *sp++;
	*dp++ = desc_arg;
	while (*sp)
		*dp++ = *sp++;
	*dp = NULL;
	execvp(execp_argv[0], execp_argv);
	fprintf(stderr, "Unable to execvp %s\n", passon_argv[0]);
	exit(1);
}