From 6d7ec6a1d0bae94138e4ad73525a42124458da14 Mon Sep 17 00:00:00 2001 From: dan Date: Thu, 15 Feb 2018 15:24:12 +0000 Subject: [PATCH] Fix another point in zonefile.c so that all files are opened in either "rb" or "wb" mode. FossilOrigin-Name: fb1c2277912c55cfae30c18b5434bc193748746395fa7df983cd8a29e5741ff9 --- ext/zonefile/zonefile.c | 20 +++++++++----------- manifest | 12 ++++++------ manifest.uuid | 2 +- 3 files changed, 16 insertions(+), 18 deletions(-) diff --git a/ext/zonefile/zonefile.c b/ext/zonefile/zonefile.c index d57faaaf56..fecb7fe95e 100644 --- a/ext/zonefile/zonefile.c +++ b/ext/zonefile/zonefile.c @@ -380,6 +380,7 @@ static void zonefileWriteFunc( FILE *pFd = 0; int rc; sqlite3_value *pPrev = 0; + char *zErr = 0; ZonefileBuffer sFrameIdx = {0, 0, 0}; ZonefileBuffer sKeyIdx = {0, 0, 0}; @@ -402,10 +403,11 @@ static void zonefileWriteFunc( if( pStmt==0 ) return; /* Open a file-handle used to write out the zonefile */ - pFd = fopen(zFile, "w"); + pFd = zonefileFileOpen(zFile, 1, &zErr); if( pFd==0 ){ - zonefileCtxError(pCtx, "error opening file \"%s\" (fopen())", zFile); + sqlite3_result_error(pCtx, zErr, -1); sqlite3_finalize(pStmt); + sqlite3_free(zErr); return; } @@ -676,14 +678,6 @@ static int zffEof(sqlite3_vtab_cursor *cur){ return pCsr->pSelect==0; } -static FILE *zonefileOpenFile(sqlite3_context *pCtx, const char *zFile){ - FILE *pFd = fopen(zFile, "r"); - if( pFd==0 ){ - zonefileCtxError(pCtx, "failed to open file for reading: \"%s\"", zFile); - } - return pFd; -} - static void zonefileHeaderDeserialize(u8 *aBuf, ZonefileHeader *pHdr){ pHdr->magicNumber = zonefileGet32(&aBuf[0]); pHdr->compressionTypeIndexData = aBuf[4]; @@ -699,7 +693,8 @@ static void zonefileHeaderDeserialize(u8 *aBuf, ZonefileHeader *pHdr){ } static void zonefileJsonHeader(sqlite3_context *pCtx, const char *zFile){ - FILE *pFd = zonefileOpenFile(pCtx, zFile); + char *zErr = 0; + FILE *pFd = zonefileFileOpen(zFile, 0, &zErr); if( pFd ){ int rc; ZonefileHeader hdr; @@ -745,6 +740,9 @@ static void zonefileJsonHeader(sqlite3_context *pCtx, const char *zFile){ } } fclose(pFd); + }else{ + sqlite3_result_error(pCtx, zErr, -1); + sqlite3_free(zErr); } } diff --git a/manifest b/manifest index b90981a17b..d23be9ea5b 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C When\scalling\sfopen()\sin\sthe\szonefile\sextension,\suse\smodes\s"rb"\sand\s"wb"\ninstead\sof\s"r"\sand\s"w".\sThis\smakes\sno\sdifference\son\sunix,\sbut\sis\srequired\swhen\naccessing\sbinary\sfiles\son\sother\ssystems. -D 2018-02-15T15:17:42.189 +C Fix\sanother\spoint\sin\szonefile.c\sso\sthat\sall\sfiles\sare\sopened\sin\seither\s"rb"\sor\n"wb"\smode. +D 2018-02-15T15:24:12.092 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F Makefile.in 7a3f714b4fcf793108042b7b0a5c720b0b310ec84314d61ba7f3f49f27e550ea @@ -409,7 +409,7 @@ F ext/userauth/sqlite3userauth.h 7f3ea8c4686db8e40b0a0e7a8e0b00fac13aa7a3 F ext/userauth/user-auth.txt e6641021a9210364665fe625d067617d03f27b04 F ext/userauth/userauth.c 3410be31283abba70255d71fd24734e017a4497f F ext/zonefile/README.md 387ad2b748e98eeea21fd4dbb609fefe313263fadb3fc6c01c512b4c95e55ae4 -F ext/zonefile/zonefile.c e6ad01c704eed24306990c1dd5dbe8b45e590c8dbb0e3a8d95cb1aec41c815c0 +F ext/zonefile/zonefile.c 88d4ba281f47d35ce5989a7c500cfd05e3c8e348426baebcb7bcef314aee08f2 F ext/zonefile/zonefile1.test 872ec8d549af0f1423601acdfe29390803fab3e14b8d5715f2f4bbd11431f1f5 F install-sh 9d4de14ab9fb0facae2f48780b874848cbf2f895 x F ltmain.sh 3ff0879076df340d2e23ae905484d8c15d5fdea8 @@ -1708,7 +1708,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P a2221e35d6c34d0c07bee9329073ad12cad4ba88437dd40cea71ae3ffc77eeef -R a0d3d52c8893df73e9ad6db01913acd7 +P 4bb854ddd9c1dc2972fd4f7c2c2b2d121caa662d5085694c2dbb35d331a61444 +R 2c56f94b965e90e1ed8c01e5183c20c8 U dan -Z 81d210b1b092270aa489eff76d621726 +Z 2cff9a10fd106f92fe182af0aacf7c32 diff --git a/manifest.uuid b/manifest.uuid index 516bb5cef2..da03a2339e 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -4bb854ddd9c1dc2972fd4f7c2c2b2d121caa662d5085694c2dbb35d331a61444 \ No newline at end of file +fb1c2277912c55cfae30c18b5434bc193748746395fa7df983cd8a29e5741ff9 \ No newline at end of file -- 2.47.2