Compare commits

..
3 Commits
Author SHA1 Message Date
avjarami d75e27a5c4 Fixing memory leaks
This change fixes memory leaks present in journal printing command line
interface and journal printing api.

Signed-off-by: avjarami <alex.v.jaramillo@intel.com>
2018-03-14 06:22:59 -07:00
avjarami 9baf5f821e Use shared random id function
Random id generation function in telemetry.c is equivalent to function
in util.c, this change reuses the function defined in util.c in
telemetry.c and removes the no longer needed function.

Signed-off-by: avjarami <alex.v.jaramillo@intel.com>
2018-03-14 06:22:59 -07:00
avjarami be98da141d Add items to ignore list
Signed-off-by: avjarami <alex.v.jaramillo@intel.com>
2018-03-14 06:22:59 -07:00
4 changed files with 9 additions and 41 deletions
+2
View File
@@ -38,6 +38,7 @@ autoscan.log
configure.scan
tprobe
hprobe
bertprobe
crashprobe
journalprobe
telem-record-gen
@@ -45,6 +46,7 @@ klogscanner
oopsprobe
pstoreclean
pstoreprobe
telem_journal
make.out
types_c.taghl
src/recomp.sh
-5
View File
@@ -102,10 +102,5 @@ int main(int argc, char **argv)
rc = EXIT_FAILURE;
}
free(classification);
free(record_id);
free(event_id);
free(boot_id);
return rc;
}
+4 -3
View File
@@ -432,13 +432,13 @@ int print_journal(TelemJournal *telem_journal, char *classification,
if (entry) {
/* filter entry out if one is provided */
if (record_id != NULL && strcmp(entry->record_id, record_id) != 0) {
continue;
goto skip_print;
}
if (boot_id != NULL && strcmp(entry->boot_id, boot_id) != 0) {
continue;
goto skip_print;
}
if (event_id != NULL && strcmp(entry->event_id, event_id) != 0) {
continue;
goto skip_print;
}
// In the case of class checking prefixes is an option
if (classification != NULL) {
@@ -460,6 +460,7 @@ int print_journal(TelemJournal *telem_journal, char *classification,
fprintf(stdout, "%-30s %s %s %s %s\n", entry->classification, str_time, entry->record_id, entry->event_id, entry->boot_id);
count++;
}
skip_print:
free_journal_entry(entry);
}
free(line);
+3 -33
View File
@@ -615,37 +615,6 @@ static int set_bios_version_header(struct telem_ref *t_ref)
return status;
}
/**
* Generates an alphanumeric id of length 32
*
* @param buff pointer to memory buffer, buffer should have
* at least 33 bytes of memory
*
* @return 0 if successful, or -1 if there's a problem
*
*/
static int gen_event_id(char *buff)
{
int frandom = -1;
int result = -1;
uint64_t random_id[2] = { 0 };
frandom = open("/dev/urandom", O_RDONLY);
if (frandom < 0) {
return -1;
}
if (read(frandom, &random_id, sizeof(random_id)) == sizeof(random_id)) {
if (sprintf(buff, "%.16" PRIx64 "%.16" PRIx64, random_id[0], random_id[1]) == 32) {
result = 0;
}
}
close(frandom);
return result;
}
/**
* Sets the event_id header, this id is an identifier that multiple
* records can share. This means that one event can lead to multiple
@@ -659,9 +628,9 @@ static int gen_event_id(char *buff)
static int set_event_id_header(struct telem_ref *t_ref)
{
int rc = 0;
char buff[33];
char *buff = NULL;
rc = gen_event_id(buff);
rc = get_random_id(&buff);
if (rc == 0) {
rc = set_header(
@@ -669,6 +638,7 @@ static int set_event_id_header(struct telem_ref *t_ref)
TM_EVENT_ID_STR, buff,
&(t_ref->record->header_size));
}
free(buff);
return rc;
}