From 8d9049942d24104f4e250396e068683ff6dfbdbb Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Wed, 24 Jun 2020 13:41:03 -0700 Subject: [PATCH 1/3] GUACAMOLE-465: Remove superfluous access check prior to attempting file deletion. --- src/guacenc/video.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/guacenc/video.c b/src/guacenc/video.c index 2dd41f16..b1ff92d8 100644 --- a/src/guacenc/video.c +++ b/src/guacenc/video.c @@ -37,10 +37,11 @@ #include #include #include +#include #include #include -#include #include +#include #include guacenc_video* guacenc_video_alloc(const char* path, const char* codec_name, @@ -166,10 +167,11 @@ guacenc_video* guacenc_video_alloc(const char* path, const char* codec_name, fail_output_file: avio_close(container_format_context->pb); - /* delete the file that was created if it was actually created */ - if (access(path, F_OK) != -1) { - remove(path); - } + + /* Delete the file that was created if it was actually created */ + if (unlink(path) == -1 && errno != ENOENT) + guacenc_log(GUAC_LOG_WARNING, "Failed output file \"%s\" could not " + "be automatically deleted: %s", path, strerror(errno)); fail_output_avio: av_freep(&frame->data[0]); From 4ac0940e812a45dde0dfeed00aab9ae73d70a4d4 Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Wed, 24 Jun 2020 13:28:52 -0700 Subject: [PATCH 2/3] GUACAMOLE-465: Remove redundant newline character from calls to guacenc_log(). --- src/guacenc/video.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/guacenc/video.c b/src/guacenc/video.c index 4d2bcf47..fdb3f359 100644 --- a/src/guacenc/video.c +++ b/src/guacenc/video.c @@ -56,7 +56,7 @@ guacenc_video* guacenc_video_alloc(const char* path, const char* codec_name, /* allocate the output media context */ avformat_alloc_output_context2(&container_format_context, NULL, NULL, path); if (container_format_context == NULL) { - guacenc_log(GUAC_LOG_ERROR, "Failed to determine container from output file name\n"); + guacenc_log(GUAC_LOG_ERROR, "Failed to determine container from output file name"); goto fail_codec; } @@ -74,7 +74,7 @@ guacenc_video* guacenc_video_alloc(const char* path, const char* codec_name, video_stream = NULL; video_stream = avformat_new_stream(container_format_context, codec); if (video_stream == NULL) { - guacenc_log(GUAC_LOG_ERROR, "Could not allocate encoder stream. Cannot continue.\n"); + guacenc_log(GUAC_LOG_ERROR, "Could not allocate encoder stream. Cannot continue."); goto fail_format_context; } video_stream->id = container_format_context->nb_streams - 1; @@ -124,7 +124,7 @@ guacenc_video* guacenc_video_alloc(const char* path, const char* codec_name, if (!(container_format->flags & AVFMT_NOFILE)) { ret = avio_open(&container_format_context->pb, path, AVIO_FLAG_WRITE); if (ret < 0) { - guacenc_log(GUAC_LOG_ERROR, "Error occurred while opening output file.\n"); + guacenc_log(GUAC_LOG_ERROR, "Error occurred while opening output file."); goto fail_output_avio; } } @@ -132,7 +132,7 @@ guacenc_video* guacenc_video_alloc(const char* path, const char* codec_name, /* write the stream header, if needed */ ret = avformat_write_header(container_format_context, NULL); if (ret < 0) { - guacenc_log(GUAC_LOG_ERROR, "Error occurred while writing output file header.\n"); + guacenc_log(GUAC_LOG_ERROR, "Error occurred while writing output file header."); failed_header = true; goto fail_output_file; } @@ -483,7 +483,7 @@ int guacenc_video_free(guacenc_video* video) { /* write trailer, if needed */ if (video->container_format_context != NULL && video->output_stream != NULL) { - guacenc_log(GUAC_LOG_DEBUG, "Writing trailer: %d\n", + guacenc_log(GUAC_LOG_DEBUG, "Writing trailer: %d", av_write_trailer(video->container_format_context) == 0 ? "success" : "failure"); } From af2c1090796a721a3f412020df620d7c29c43d1b Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Wed, 24 Jun 2020 13:31:45 -0700 Subject: [PATCH 3/3] GUACAMOLE-465: Correct printf-style format string (should be "%s" for strings, not "%d"). --- src/guacenc/video.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/guacenc/video.c b/src/guacenc/video.c index fdb3f359..e2eed51f 100644 --- a/src/guacenc/video.c +++ b/src/guacenc/video.c @@ -483,7 +483,7 @@ int guacenc_video_free(guacenc_video* video) { /* write trailer, if needed */ if (video->container_format_context != NULL && video->output_stream != NULL) { - guacenc_log(GUAC_LOG_DEBUG, "Writing trailer: %d", + guacenc_log(GUAC_LOG_DEBUG, "Writing trailer: %s", av_write_trailer(video->container_format_context) == 0 ? "success" : "failure"); }