Check-in [c6265bb3a7]
Not logged in

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

Overview
Comment:Raise an error when trying to insert an unversioned file if the file size would cause the database row to exceed SQLITE_LIMIT_LENGTH.
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: c6265bb3a7eb867d2a960594d2886ce7c65219d416a031be323482b5edf26c43
User & Date: drh 2025-08-10 10:28:08.209
Context
2025-08-13
15:48
Allow the mimetype query parameter for non-CGI content in /ext. check-in: 639b96b9ad user: drh tags: trunk
2025-08-12
15:04
Revamp the Copy Buttons for a more responsive user experience. See the wiki page linked to this branch for more details. check-in: 32c3a210c8 user: florian tags: copybtn.js-responsive
2025-08-10
10:28
Raise an error when trying to insert an unversioned file if the file size would cause the database row to exceed SQLITE_LIMIT_LENGTH. check-in: c6265bb3a7 user: drh tags: trunk
2025-08-07
19:46
Add an assert() in a block which cannot happen. It survives 'reconstruct', so we can probably remove the block, but leaving it around for a while seems prudent. check-in: 7d4af37f39 user: stephan tags: trunk
Changes
Side-by-Side Diff Ignore Whitespace Patch
Changes to src/unversioned.c.
318
319
320
321
322
323
324



325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340


341
342
343




344
345
346
347
348
349
350
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359







+
+
+
















+
+



+
+
+
+







  }
  if( strncmp(zCmd, "add", nCmd)==0 ){
    const char *zError = 0;
    const char *zIn;
    const char *zAs;
    Blob file;
    int i;
    i64 mxSize = sqlite3_limit(g.db,SQLITE_LIMIT_LENGTH,-1) - 850;
                   /* Extra space for other fields      ------^^^  */
                   /* of the UNVESIONED table row.                 */

    zAs = find_option("as",0,1);
    verify_all_options();
    if( zAs && g.argc!=4 ) usage("add DISKFILE --as UVFILE");
    db_begin_transaction();
    content_rcvid_init("#!fossil unversioned add");
    for(i=3; i<g.argc; i++){
      zIn = zAs ? zAs : g.argv[i];
      if( zIn[0]==0 ){
        zError = "be empty string";
      }else if( zIn[0]=='/' ){
        zError = "be absolute";
      }else if ( !file_is_simple_pathname(zIn,1) ){
        zError = "contain complex paths";
      }else if( contains_whitespace(zIn) ){
        zError = "contain whitespace";
      }else if( strlen(zIn)>500 ){
        zError = "be more than 500 bytes long";
      }
      if( zError ){
        fossil_fatal("unversioned filenames may not %s: %Q", zError, zIn);
      }
      if( file_size(g.argv[i], ExtFILE)>mxSize ){
        fossil_fatal("file \"%s\" is too big; max size: %,lld bytes",
                     g.argv[i], mxSize);
      }
      blob_init(&file,0,0);
      blob_read_from_file(&file, g.argv[i], ExtFILE);
      unversioned_write(zIn, &file, mtime);
      blob_reset(&file);
    }
    db_end_transaction(0);