X-Git-Url: http://git.ozlabs.org/?p=petitboot;a=blobdiff_plain;f=lib%2Ffile%2Ffile.c;h=6028005712788c9b8dd8c4d552561f211f2fcdcd;hp=0d187887c701f75183fcec4550f33cb292a9198a;hb=df1a234c15fbe215b0dd0d75c760f47c2dab411f;hpb=de2f990a98718d15bff074b9ae65f2eb92a2f938 diff --git a/lib/file/file.c b/lib/file/file.c index 0d18788..6028005 100644 --- a/lib/file/file.c +++ b/lib/file/file.c @@ -37,14 +37,13 @@ int copy_file_secure_dest(void *ctx, const char *source_file, char **destination_file) { char readlink_buffer[MAX_FILENAME_SIZE + 1]; - char dest_filename[MAX_FILENAME_SIZE] = ""; + char dest_filename[MAX_FILENAME_SIZE + 1] = ""; char template[] = "/tmp/petitbootXXXXXX"; FILE *destination_handle, *source_handle; int destination_fd, result = 0; unsigned char *buffer; ssize_t r; size_t l1; - mode_t oldmask; source_handle = fopen(source_file, "r"); if (!source_handle) { @@ -53,17 +52,15 @@ int copy_file_secure_dest(void *ctx, const char *source_file, return -1; } - oldmask = umask(0644); destination_fd = mkstemp(template); - umask(oldmask); if (destination_fd < 0) { - pb_log("%s: unable to create temp file, %m\n", __func__); + pb_log_fn("unable to create temp file, %m\n"); fclose(source_handle); return -1; } destination_handle = fdopen(destination_fd, "w"); if (!destination_handle) { - pb_log("%s: unable to open destination file, %m\n", __func__); + pb_log_fn("unable to open destination file, %m\n"); fclose(source_handle); close(destination_fd); return -1; @@ -84,7 +81,7 @@ int copy_file_secure_dest(void *ctx, const char *source_file, if (ferror(destination_handle)) { /* General error */ result = -1; - pb_log("%s: failed: unknown fault\n", __func__); + pb_log_fn("failed: unknown fault\n"); } else { /* No space on destination device */