Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion c_sourcecode/src/archive/archive.c
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ int archive_create_smart(const dump_file_t *dump, const config_t *config,
while ((tmp = strstr(new_dump_name, pattern)) != NULL)
{
*tmp = '_';
strcpy(tmp + 1, tmp + pattern_len);
memmove(tmp + 1, tmp + pattern_len, strlen(tmp + pattern_len) + 1);
}
CRASHUPLOAD_INFO("archive_create_smart() After process dump name=%s\n", new_dump_name);

Expand Down
2 changes: 1 addition & 1 deletion c_sourcecode/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ int main_test(int argc, char *argv[])
goto cleanup;
}

memset(archive, '\0', dump_count * sizeof(archive));
memset(archive, '\0', dump_count * sizeof(*archive));
/* 5.2: Process each dump */
for (int i = 0; i < dump_count; i++)
{
Expand Down
3 changes: 1 addition & 2 deletions c_sourcecode/src/platform/platform.c
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,7 @@ size_t GetEstbMac(char *pEstbMac, size_t szBufSize)
{
if (NULL != (fgets(pEstbMac, szBufSize, fp)))
{ // better be a valid string on first line
i = stripinvalidchar(pEstbMac, szBufSize);
}
}
Comment on lines 142 to +144
fclose(fp);
i = stripinvalidchar(pEstbMac, szBufSize);
CRASHUPLOAD_INFO("GetEstbMac: After reading %s value=%s\n", MAC_FILE, pEstbMac);
Expand Down
10 changes: 3 additions & 7 deletions c_sourcecode/src/ratelimit/ratelimit.c
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ int is_upload_limit_reached(const char *file)
}

/* Validate numeric content of FIRST line */
for (size_t i = 0; first_line_data[i] != '\0' && first_line_data[i] != '\n' && i < sizeof(first_line_data); i++)
for (size_t i = 0; i < sizeof(first_line_data) && first_line_data[i] != '\0' && first_line_data[i] != '\n'; i++)
{
if (!isdigit((unsigned char)first_line_data[i]))
{
Expand Down Expand Up @@ -171,7 +171,6 @@ int is_upload_limit_reached(const char *file)

int is_recovery_time_reached(const char *deny_file)
{
struct stat st;
FILE *fp;
char buf[32];
char *endptr;
Expand All @@ -181,10 +180,7 @@ int is_recovery_time_reached(const char *deny_file)
if (!deny_file)
return ALLOW_UPLOAD; /* allow upload */

/* If deny file does not exist, allow */
if (stat(deny_file, &st) != 0)
return ALLOW_UPLOAD;

/* Open directly; let fopen() report absence atomically */
fp = fopen(deny_file, "r");
if (!fp)
return ALLOW_UPLOAD;
Expand All @@ -197,7 +193,7 @@ int is_recovery_time_reached(const char *deny_file)
fclose(fp);

/* Validate numeric content with bounds check */
for (size_t i = 0; buf[i] != '\0' && buf[i] != '\n' && i < sizeof(buf); i++)
for (size_t i = 0; i < sizeof(buf) && buf[i] != '\0' && buf[i] != '\n'; i++)
{
if (!isdigit((unsigned char)buf[i]))
return ALLOW_UPLOAD;
Expand Down
4 changes: 2 additions & 2 deletions c_sourcecode/src/scanner/scanner.c
Original file line number Diff line number Diff line change
Expand Up @@ -605,8 +605,8 @@ int processCrashTelemetryInfo(const char *rawfile, const char *log_path, bool t2
snprintf(Appname, sizeof(Appname), "%s", us + 1);

size_t pnamelen = (size_t)(us - containerName);
if (pnamelen >= sizeof(ProcessName))
pnamelen = sizeof(ProcessName) - 1;
if (pnamelen >= sizeof(containerName))
pnamelen = sizeof(containerName) - 1;
memcpy(ProcessName, containerName, pnamelen);
ProcessName[pnamelen] = '\0';
}
Expand Down
2 changes: 1 addition & 1 deletion c_sourcecode/src/utils/cleanup_batch.c
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,7 @@ void remove_pending_dumps(const char *working_dir,

snprintf(path, sizeof(path), "%s/%s", working_dir, entry->d_name);

if (stat(path, &st) < 0)
if (lstat(path, &st) < 0)
{
CRASHUPLOAD_WARN("stat Error: %s\n", path);
continue;
Expand Down
6 changes: 3 additions & 3 deletions c_sourcecode/src/utils/prerequisites.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,11 @@ void defer_upload_if_needed(device_type_t device_type)

int uptime_val = (int)uptime_seconds;

if (uptime_val < FOUR_EIGHTY_SECS)
if (uptime_val < FOUR_EIGHTY_SECS && uptime_val >= 0)
Comment on lines 64 to +66
{

int sleep_time = FOUR_EIGHTY_SECS - uptime_val;

CRASHUPLOAD_INFO("Deferring Upload for %d seconds\n", sleep_time);
sleep(sleep_time);
CRASHUPLOAD_INFO("Deferring Upload for %d seconds completed\n", sleep_time);
Expand Down
Loading