Skip to content
Open
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
10 changes: 10 additions & 0 deletions host/libraries/libbladeRF/src/bladerf.c
Original file line number Diff line number Diff line change
Expand Up @@ -2234,6 +2234,12 @@ int bladerf_load_gain_calibration(struct bladerf *dev, bladerf_channel ch, const
}

if (cal_file_loc != NULL) {
if (strlen(cal_file_loc) >= filename_len) {
log_error("Gain calibration path is too long (%zu >= %zu)\n",
strlen(cal_file_loc), filename_len);
status = BLADERF_ERR_INVAL;
goto error;
}
strcpy(filename, cal_file_loc);
} else {
log_debug("No calibration file specified, using serial number\n");
Expand All @@ -2256,6 +2262,10 @@ int bladerf_load_gain_calibration(struct bladerf *dev, bladerf_channel ch, const

/** Convert to binary format if CSV */
full_path_bin = (char*)malloc(strlen(full_path) + 1);
if (full_path_bin == NULL) {
status = BLADERF_ERR_MEM;
goto error;
}
strcpy(full_path_bin, full_path);
ext = strstr(full_path_bin, ".csv");
if (ext) {
Expand Down
8 changes: 6 additions & 2 deletions host/libraries/libbladeRF/src/device_calibration.c
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,13 @@ int gain_cal_csv_to_bin(struct bladerf *dev, const char *csv_path, const char *b
if (!csvFile || !binaryFile) {
status = BLADERF_ERR_NO_FILE;
if (getcwd(current_dir, sizeof(current_dir)) != NULL) {
log_error("Error opening calibration file: %s\n", strcat(current_dir, csv_path));
/* strcat() here appends a caller-supplied path of arbitrary
* length to a buffer already holding the working directory,
* overflowing it for long paths. Print the two parts instead. */
log_error("Error opening calibration file: %s/%s\n",
current_dir, csv_path);
} else {
log_error("Error opening calibration file\n");
log_error("Error opening calibration file: %s\n", csv_path);
}
goto error;
}
Expand Down