Skip to content
Snippets Groups Projects
Commit 2a6ebaaa authored by Raphael Defosseux's avatar Raphael Defosseux
Browse files

Fixes on the array size computation.

This work is based on feedback from Thomas Schlichter.
His comments and suggestions were made just after the original MR was merged.

Signed-off-by: default avatarRaphael Defosseux <raphael.defosseux@eurecom.fr>
parent 530b74dd
No related branches found
No related tags found
4 merge requests!1757Draft: Use pMAX value in configuration file, instead of hardcoded '23' in asn1_msg.c,!1493fix DL arq errors in UE,!1185Integration 2021 wk24,!1179Fix Incorrect Array Size computation
......@@ -96,14 +96,14 @@ static void read_pipe(int p, char *b, int size) {
}
}
static int baseRunTimeCommand(char* cmd) {
static int baseRunTimeCommand(char* cmd, size_t cmdSize) {
FILE *fp;
size_t retSize = 0;
fp = popen(cmd, "r");
memset(cmd, 1, sizeof(*cmd));
retSize = fread(cmd, 1, sizeof(*cmd), fp);
memset(cmd, 0, cmdSize);
retSize = fread(cmd, 1, cmdSize, fp);
fclose(fp);
if (retSize == 0) {
......@@ -115,26 +115,26 @@ static int baseRunTimeCommand(char* cmd) {
int checkIfFedoraDistribution(void) {
char cmd[200];
memset(cmd, 1, 200);
memset(cmd, 0, 200);
sprintf(cmd, "cat /etc/os-release | grep ID_LIKE | grep -ic fedora || true");
return baseRunTimeCommand(cmd);
return baseRunTimeCommand(cmd, 200);
}
int checkIfGenericKernelOnFedora(void) {
char cmd[200];
memset(cmd, 1, 200);
memset(cmd, 0, 200);
sprintf(cmd, "uname -a | grep -c rt || true");
return (1 - baseRunTimeCommand(cmd));
return (1 - baseRunTimeCommand(cmd, 200));
}
int checkIfInsideContainer(void) {
char cmd[200];
int res = 0;
memset(cmd, 1, 200);
memset(cmd, 0, 200);
sprintf(cmd, "cat /proc/self/cgroup | egrep -c 'libpod|podman|kubepods' || true");
res = baseRunTimeCommand(cmd);
res = baseRunTimeCommand(cmd, 200);
if (res > 0)
return 1;
else
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment