Skip to content
This repository was archived by the owner on Feb 12, 2024. It is now read-only.
This repository was archived by the owner on Feb 12, 2024. It is now read-only.

Adding files preserving mode or mtime results in data corruption #4093

Closed
@kstuart

Description

@kstuart

Linux ce937568e283 5.17.5-arch1-1 #1 SMP PREEMPT Wed, 27 Apr 2022 20:56:11 +0000 x86_64 Linux

js-ipfs version: 0.15.2-0078aad85f92d7bc8e3a22eb9ef8efd257b439b5
interface-ipfs-core version: ^0.155.0
ipfs-http-client version: 1.0.0
Repo version: 12
System version: x64/linux
Node.js version: v16.4.2
Commit: 0078aad

jsipfs run in daemon offline mode

Steps to reproduce with --preserve-mtime (empty file)

touch -d@1652299617 /tmp/empty_file
jsipfs add --preserve-mtime /tmp/empty_file
added QmcrCRhLSqsroGBX2PyBtdCrKWBDxjgPpATLg3KxMqywna empty_file

jsipfs files stat /ipfs/QmcrCRhLSqsroGBX2PyBtdCrKWBDxjgPpATLg3KxMqywna
QmcrCRhLSqsroGBX2PyBtdCrKWBDxjgPpATLg3KxMqywna
Size: 6
CumulativeSize: 22
ChildBlocks: 0
Type: file
Mode: -rw-r--r--
Mtime: May 11, 2022, 08:06:57 PM UTC

jsipfs get QmcrCRhLSqsroGBX2PyBtdCrKWBDxjgPpATLg3KxMqywna
Saving file(s) QmcrCRhLSqsroGBX2PyBtdCrKWBDxjgPpATLg3KxMqywna

xxd QmcrCRhLSqsroGBX2PyBtdCrKWBDxjgPpATLg3KxMqywna
00000000: 0a04 0802 1800 ......

Expected:

The file 'QmcrCRhLSqsroGBX2PyBtdCrKWBDxjgPpATLg3KxMqywna' to have size 0 and contain no data.


Steps to reproduce with --preserve-mode (file with content)

echo -n "A" > /tmp/test_file
touch -d@1652299617 /tmp/test_file
jsipfs add --preserve-mode /tmp/test_file

added QmW198BawsGUvwKQN8hxUHKdCNSS3fYf7pMmPQujUAJnBH test_file

jsipfs files stat /ipfs/QmW198BawsGUvwKQN8hxUHKdCNSS3fYf7pMmPQujUAJnBH
QmW198BawsGUvwKQN8hxUHKdCNSS3fYf7pMmPQujUAJnBH
Size: 9
CumulativeSize: 17
ChildBlocks: 0
Type: file
Mode: -rw-r--r--
Mtime:

jsipfs get QmW198BawsGUvwKQN8hxUHKdCNSS3fYf7pMmPQujUAJnBH
Saving file(s) QmW198BawsGUvwKQN8hxUHKdCNSS3fYf7pMmPQujUAJnBH

xxd QmW198BawsGUvwKQN8hxUHKdCNSS3fYf7pMmPQujUAJnBH
00000000: 0a07 0802 1201 4118 01 ......A..

xxd /tmp/test_file
00000000: 41 A

Expected:

The file 'QmW198BawsGUvwKQN8hxUHKdCNSS3fYf7pMmPQujUAJnBH' to have size 1 and its content to exactly match /tmp/test_file.

Metadata

Metadata

Assignees

Labels

P2Medium: Good to have, but can wait until someone steps uphelp wantedSeeking public contribution on this issuekind/bugA bug in existing code (including security flaws)kind/maybe-in-helianeed/analysisNeeds further analysis before proceeding

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions