]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Detect an OOM condition in the realpath() function of the fileio.c extension
authordrh <>
Wed, 10 Jun 2026 10:40:29 +0000 (10:40 +0000)
committerdrh <>
Wed, 10 Jun 2026 10:40:29 +0000 (10:40 +0000)
and cause that function to return NULL.  To Do:  we should go back in and
fix realpath() to raise an SQLITE_NOMEM error on OOM rather than returning
NULL.  But we will delay that, in as much as OOMs are all but impossible
on modern OSes.
[bug:/info/2026-06-10T07:46:32Z|Bug 2026-06-10T07:46:32Z].

FossilOrigin-Name: 8b961dc3d27c5aa62a5dc7c2e44f8b505817e184f8499f3bb903e06b5aec1b72

ext/misc/fileio.c
manifest
manifest.uuid

index 3c58683966a5740f81e5b911449b705c97705acf..16f647b112e8bf576dcd6ddccd48bfcbe10fa86b 100644 (file)
@@ -1165,6 +1165,9 @@ static char *portable_realpath(const char *zPath){
 ** The file or directory X is not required to exist.  The answer is formed
 ** by calling system realpath() on the prefix of X that does exist and
 ** appending the tail of X that does not (yet) exist.
+**
+** FIXME:  This routine sometimes returns NULL rather than raising
+** an SQLITE_NOMEM error if an OOM is encountered.
 */
 static void realpathFunc(
   sqlite3_context *context,
@@ -1187,6 +1190,7 @@ static void realpathFunc(
   if( zPath==0 ) return;
   if( zPath[0]==0 ) zPath = ".";
   zCopy = sqlite3_mprintf("%s",zPath);
+  if( zCopy==0 ) return;
   len = strlen(zCopy);
   while( len>1 && (zCopy[len-1]=='/' || (isWin && zCopy[len-1]=='\\')) ){
     len--;
index 2e31aad7e4126275375386e850ea4403faed5394..04aa4d14ceb46003b9ae064fa3b3d79cdc26db59 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Fix\sa\spossible\ssigned\sinteger\soverflow\sin\sthe\sRBU\sextension\sgiven\sa\s\nmaliciously\scrafted\sdelta.\n[bugs:/info/2026-06-10T06:41:54Z|Bug\s2026-06-10T06:41:54Z].
-D 2026-06-10T10:13:11.352
+C Detect\san\sOOM\scondition\sin\sthe\srealpath()\sfunction\sof\sthe\sfileio.c\sextension\nand\scause\sthat\sfunction\sto\sreturn\sNULL.\s\sTo\sDo:\s\swe\sshould\sgo\sback\sin\sand\nfix\srealpath()\sto\sraise\san\sSQLITE_NOMEM\serror\son\sOOM\srather\sthan\sreturning\nNULL.\s\sBut\swe\swill\sdelay\sthat,\sin\sas\smuch\sas\sOOMs\sare\sall\sbut\simpossible\non\smodern\sOSes.\n[bug:/info/2026-06-10T07:46:32Z|Bug\s2026-06-10T07:46:32Z].
+D 2026-06-10T10:40:29.851
 F .fossil-settings/binary-glob 61195414528fb3ea9693577e1980230d78a1f8b0a54c78cf1b9b24d0a409ed6a x
 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
@@ -378,7 +378,7 @@ F ext/misc/decimal.c 432e5b03a0e2a68a1846a9852a565a1b546ca9b295deda834e4653f0f55
 F ext/misc/diskused.c 8acb4f27488fd8b9bdb0a3d300a7bd761b797b6e7858ac8038398263cededc48
 F ext/misc/eval.c 04bc9aada78c888394204b4ed996ab834b99726fb59603b0ee3ed6e049755dc1
 F ext/misc/explain.c 9670c8ff7b255eea7845abc5123a4958e74016c16990b10497e56380f91704b9
-F ext/misc/fileio.c 936c0a7b3382a047d833ad33f62ba59a3847b79ea745bf529797cd344966fbb0
+F ext/misc/fileio.c a8caf3ffb59af6e9870d1a1c739981727ba165cd667bda085fa21ccfc8694059
 F ext/misc/fossildelta.c 37b67b2710a0dd2da7b3aeea19388a069471eb0fc04702a0521237770d0d04f1
 F ext/misc/fuzzer.c decaca5a3479dfba69576cd41d4e17161eaf154a5438e12d316bbc5853571802
 F ext/misc/ieee754.c 2901d08a586d00a1d3c0fd89e03c57ee9e2b5f013b0daab9e49c7a48a9d5946b
@@ -2209,8 +2209,8 @@ F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee
 F tool/warnings.sh a554d13f6e5cf3760f041b87939e3d616ec6961859c3245e8ef701d1eafc2ca2
 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
 F tool/winmain.c 00c8fb88e365c9017db14c73d3c78af62194d9644feaf60e220ab0f411f3604c
-P 67271c31292bc1bddbb5e144c881c85c9f91b3963a1db4bae1f738adab50f7c0
-R b224659e1174fe80709ad63ac28f8f96
+P 8531c0c3b61771592b055b0c22e903b8301a4161c7bcb7f9fc54d730b080d095
+R e5883d962c09aada766147417d09223f
 U drh
-Z 3001a5b8c9895141a1a25fda76421de5
+Z a34b1cb702dc031fc82fc684719a074c
 # Remove this line to create a well-formed Fossil manifest.
index 7583a551c9c0ed90b8e03283aa5d86d3d9146d51..672d015f6391262afcec685911be95af6aac0ef0 100644 (file)
@@ -1 +1 @@
-8531c0c3b61771592b055b0c22e903b8301a4161c7bcb7f9fc54d730b080d095
+8b961dc3d27c5aa62a5dc7c2e44f8b505817e184f8499f3bb903e06b5aec1b72