- snprintf(filename, 512, "%s/index%d", blerg->base_path, new_segment);
+ snprintf(filename, FILENAME_MAX, "%s/index%d", blerg->base_path, new_segment);
blerg->index_fd = open(filename, O_RDWR | O_CREAT, 0600);
if (blerg->index_fd == -1) {
perror("Could not open index");
blerg->index_fd = open(filename, O_RDWR | O_CREAT, 0600);
if (blerg->index_fd == -1) {
perror("Could not open index");
- sprintf(filename, "%s/data%d", blerg->base_path, new_segment);
+ snprintf(filename, FILENAME_MAX, "%s/data%d", blerg->base_path, new_segment);
blerg->data_fd = open(filename, O_RDWR | O_APPEND | O_CREAT, 0600);
if (blerg->data_fd == -1) {
perror("Could not open data");
blerg->data_fd = open(filename, O_RDWR | O_APPEND | O_CREAT, 0600);
if (blerg->data_fd == -1) {
perror("Could not open data");
- snprintf(filename, 512, "%s/%s", blergconf.data_path, name);
+ snprintf(filename, FILENAME_MAX, "%s/%s", blergconf.data_path, name);
- blerg->base_path = malloc(512);
- snprintf(blerg->base_path, 512, "%s/%s", blergconf.data_path, name);
+ blerg->base_path = malloc(FILENAME_MAX);
+ snprintf(blerg->base_path, FILENAME_MAX, "%s/%s", blergconf.data_path, name);
if (access(blerg->base_path, F_OK) == -1)
mkdir(blerg->base_path, 0755);
/* Open and map metadata */
if (access(blerg->base_path, F_OK) == -1)
mkdir(blerg->base_path, 0755);
/* Open and map metadata */
- snprintf(filename, 512, "%s/meta", blerg->base_path);
+ snprintf(filename, FILENAME_MAX, "%s/meta", blerg->base_path);
blerg->meta_fd = open(filename, O_RDWR | O_CREAT, 0600);
if (blerg->meta_fd == -1) {
perror("Could not open metadata");
blerg->meta_fd = open(filename, O_RDWR | O_CREAT, 0600);
if (blerg->meta_fd == -1) {
perror("Could not open metadata");