aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2019-12-06 17:24:52 +0100
committerDaniel Stenberg <daniel@haxx.se>2019-12-06 23:02:24 +0100
commit147fa0689124e7b5a61afea2e7db673d8c89934f (patch)
treed1034773f14f1ddc2f6d886c4aa734870ca0767a /src
parentb62038bfa6d4830a3462c08ae8aa81aea83fd970 (diff)
curl: make the etag load logic work without fseek
The fseek()s were unnecessary and caused Coverity warning CID 1456554 Closes #4681
Diffstat (limited to 'src')
-rw-r--r--src/tool_operate.c19
1 files changed, 3 insertions, 16 deletions
diff --git a/src/tool_operate.c b/src/tool_operate.c
index e78cc4fd2..4c9b07e39 100644
--- a/src/tool_operate.c
+++ b/src/tool_operate.c
@@ -922,7 +922,6 @@ static CURLcode single_transfer(struct GlobalConfig *global,
if(config->etag_compare_file) {
char *etag_from_file = NULL;
char *header = NULL;
- size_t file_size = 0;
/* open file for reading: */
FILE *file = fopen(config->etag_compare_file, FOPEN_READTEXT);
@@ -935,23 +934,11 @@ static CURLcode single_transfer(struct GlobalConfig *global,
break;
}
- /* get file size */
- fseek(file, 0, SEEK_END);
- file_size = ftell(file);
-
- /*
- * check if file is empty, if it's not load etag
- * else continue with empty etag
- */
- if(file_size != 0) {
- fseek(file, 0, SEEK_SET);
- file2string(&etag_from_file, file);
-
+ if((PARAM_OK == file2string(&etag_from_file, file)) &&
+ etag_from_file)
header = aprintf("If-None-Match: \"%s\"", etag_from_file);
- }
- else {
+ else
header = aprintf("If-None-Match: \"\"");
- }
if(!header) {
warnf(