SQLite

Check-in [b829dd1b]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Fix handling of unix paths that contain ".." components such that "/" is considered its own parent directory. Forum thread caa46bd1f2f2a255.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: b829dd1b976454619ca04c69aec5ebb5a2286772f4267b82ab2ea5fdb81ccd41
User & Date: dan 2023-01-10 15:07:18
Original Comment: Fix handling of unix paths that contain ".." components such that "/" is considered its own parent directory.
Context
2023-01-10
19:57
When computing the datatypes for columns in a view, use the same datatype name as the underlying table if such is available and is consistent with the computed affinity of the column. Forum thread 7fb1fe9dcf310ef5. (check-in: 497a9836 user: drh tags: trunk)
15:07
Fix handling of unix paths that contain ".." components such that "/" is considered its own parent directory. Forum thread caa46bd1f2f2a255. (check-in: b829dd1b user: dan tags: trunk)
14:33
Improvements to the SQLITE_DIRECTONLY documentation. (check-in: b277ba40 user: drh tags: trunk)
14:31
Fix handling of unix paths that contain ".." components such that "/" is considered its own parent directory. (Closed-Leaf check-in: 3c6cadb3 user: dan tags: unix-path-fix)
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/os_unix.c.

6458
6459
6460
6461
6462
6463
6464
6465
6466
6467
6468
6469
6470

6471
6472
6473
6474
6475
6476
6477
  int nName            /* Number of significant bytes in zName */
){
  assert( nName>0 );
  assert( zName!=0 );
  if( zName[0]=='.' ){
    if( nName==1 ) return;
    if( zName[1]=='.' && nName==2 ){
      if( pPath->nUsed<=1 ){
        pPath->rc = SQLITE_ERROR;
        return;
      }
      assert( pPath->zOut[0]=='/' );
      while( pPath->zOut[--pPath->nUsed]!='/' ){}

      return;
    }
  }
  if( pPath->nUsed + nName + 2 >= pPath->nOut ){
    pPath->rc = SQLITE_ERROR;
    return;
  }







|
<
<
<
|
|
>







6458
6459
6460
6461
6462
6463
6464
6465



6466
6467
6468
6469
6470
6471
6472
6473
6474
6475
  int nName            /* Number of significant bytes in zName */
){
  assert( nName>0 );
  assert( zName!=0 );
  if( zName[0]=='.' ){
    if( nName==1 ) return;
    if( zName[1]=='.' && nName==2 ){
      if( pPath->nUsed>1 ){



        assert( pPath->zOut[0]=='/' );
        while( pPath->zOut[--pPath->nUsed]!='/' ){}
      }
      return;
    }
  }
  if( pPath->nUsed + nName + 2 >= pPath->nOut ){
    pPath->rc = SQLITE_ERROR;
    return;
  }

Changes to test/symlink.test.

202
203
204
205
206
207
208




























209
210
  db close
  sqlite3 db w/test.db
  db eval { SELECT * FROM t1 }
} {hello world}
do_test 4.4.2 {
  list [file exists x/test.db-wal] [file exists w/test.db-wal]
} {1 0}





























finish_test







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>


202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
  db close
  sqlite3 db w/test.db
  db eval { SELECT * FROM t1 }
} {hello world}
do_test 4.4.2 {
  list [file exists x/test.db-wal] [file exists w/test.db-wal]
} {1 0}

#-------------------------------------------------------------------------
# Check that extra ".." in a path are ignored.
reset_db
do_execsql_test 5.0 {
  CREATE TABLE xyz(x, y, z);
  INSERT INTO xyz VALUES(1, 2, 3);
}

set path [pwd]
set nLink [llength [split $path /]]
set path "[string repeat ../ [expr $nLink*2]]..${path}/test.db"

sqlite3 db2 $path
do_execsql_test -db db2 5.1 {
  SELECT * FROM xyz;
} {1 2 3}
db close

forcedelete test.db2
file link test.db2 $path
sqlite3 db2 test.db2
do_execsql_test -db db2 5.2 {
  SELECT * FROM xyz;
} {1 2 3}
forcedelete test.db2



finish_test