Telegram Drive
  • Go 88.7%
  • PLpgSQL 6.9%
  • TypeSpec 4.2%
  • Shell 0.2%
Find a file
Sai Asish Y e65fbe1d8d
reader: bounds-check r.pos and currentRange.PartNo in getPartReader (#565)
* reader: bounds-check r.pos and currentRange.PartNo in getPartReader

getPartReader indexes r.ranges and r.parts directly without any
length guard:

    currentRange := r.ranges[r.pos]
    partId := r.parts[currentRange.PartNo].ID

r.ranges and r.parts can drift - a user-visible byte range is
computed from the request, but r.parts is populated from storage at
a different moment, and a stale currentRange.PartNo then indexes
past the end of r.parts. The result is a runtime panic

    panic: runtime error: index out of range [5] with length 1
      internal/reader/reader.go:136 (getPartReader)

that kills the stream goroutine mid-download and shows up as random
crashes in production (#553).

Validate r.pos against len(r.ranges) and currentRange.PartNo against
len(r.parts) before dereferencing, returning a plain error so the
HTTP handler responds with a 500 instead of the server tipping over.
No behaviour change on any well-formed request; only the
inconsistent-state branch changes from panic to error.

Fixes #553

* reader: compare currentRange.PartNo in int64 to avoid 32-bit overflow

int(currentRange.PartNo) on a 32-bit architecture can truncate large
PartNo values down into the len(r.parts) range, letting the bounds
check pass and the subsequent index panic anyway. Compare as int64
against int64(len(r.parts)) instead. Raised by gemini-code-assist
on #565.

Signed-off-by: SAY-5 <SAY-5@users.noreply.github.com>

---------

Signed-off-by: SAY-5 <SAY-5@users.noreply.github.com>
Co-authored-by: SAY-5 <SAY-5@users.noreply.github.com>
2026-04-21 14:51:13 +05:30
.github feat: migrate to Jet SQL, add River queue, and introduce sync jobs 2026-04-06 21:55:44 +05:30
.opencode feat: add BLAKE3 tree hashing support for file integrity verification 2026-02-02 09:49:03 +05:30
.vscode fix: update E-Tag header to ETag in FilesStream function 2025-08-01 20:22:02 +05:30
cmd refactor: isolate server startup lifecycle 2026-04-10 23:46:06 +05:30
docs feat: migrate to Jet SQL, add River queue, and introduce sync jobs 2026-04-06 21:55:44 +05:30
internal reader: bounds-check r.pos and currentRange.PartNo in getPartReader (#565) 2026-04-21 14:51:13 +05:30
openapi fix: align file HEAD responses with range metadata 2026-04-10 00:34:15 +05:30
pkg refactor: isolate server startup lifecycle 2026-04-10 23:46:06 +05:30
scripts feat: migrate to Jet SQL, add River queue, and introduce sync jobs 2026-04-06 21:55:44 +05:30
tests refactor: isolate server startup lifecycle 2026-04-10 23:46:06 +05:30
typespec fix: align file HEAD responses with range metadata 2026-04-10 00:34:15 +05:30
ui feat: add Openapi generator remove go-gin,fx 2024-12-31 18:51:34 +05:30
.gitignore feat: migrate to Jet SQL, add River queue, and introduce sync jobs 2026-04-06 21:55:44 +05:30
.golangci.yml feat: add integration tests and improve indexing performance 2026-01-17 11:54:41 +05:30
.goreleaser.yml refactor: logging and fix lint errors 2026-01-07 20:54:52 +05:30
.ogen.yml feat: migrate to Jet SQL, add River queue, and introduce sync jobs 2026-04-06 21:55:44 +05:30
AGENTS.md feat: add integration tests and improve indexing performance 2026-01-17 11:54:41 +05:30
config.sample.toml feat: migrate to Jet SQL, add River queue, and introduce sync jobs 2026-04-06 21:55:44 +05:30
config.sample.yml feat: migrate to Jet SQL, add River queue, and introduce sync jobs 2026-04-06 21:55:44 +05:30
CONTRIBUTING.md chore(docs): update contributing guide 2025-01-18 14:28:39 +00:00
gen.go feat: migrate to Jet SQL, add River queue, and introduce sync jobs 2026-04-06 21:55:44 +05:30
go.mod feat: migrate to Jet SQL, add River queue, and introduce sync jobs 2026-04-06 21:55:44 +05:30
go.sum feat: migrate to Jet SQL, add River queue, and introduce sync jobs 2026-04-06 21:55:44 +05:30
goreleaser.dockerfile refactor: logging and fix lint errors 2026-01-07 20:54:52 +05:30
LICENSE docs: Update LICENSE 2024-02-13 16:13:39 +05:30
main.go feat: migrate to Jet SQL, add River queue, and introduce sync jobs 2026-04-06 21:55:44 +05:30
README.md chore(docs): add DeepWiki badge 2025-06-11 15:00:43 +05:30
Taskfile.yml feat: migrate to Jet SQL, add River queue, and introduce sync jobs 2026-04-06 21:55:44 +05:30
tspconfig.yaml feat: migrate to Jet SQL, add River queue, and introduce sync jobs 2026-04-06 21:55:44 +05:30
VERSION Version 1.8.3 2026-02-15 21:40:14 +05:30

Teldrive

Ask DeepWiki

Teldrive is a powerful utility that enables you to organise your telegram files and much more.

Advantages Over Alternative Solutions

  • Exceptional Speed: Teldrive stands out among similar tools, thanks to its implementation in Go, a language known for its efficiency. Its performance surpasses alternatives written in Python and other languages, with the exception of Rust.

  • Enhanced Management Capabilities: Teldrive not only excels in speed but also offers an intuitive user interface for efficient file interaction which other tool lacks. Its compatibility with Rclone further enhances file management.

Important

Teldrive functions as a wrapper over your Telegram account, simplifying file access. However, users must adhere to the limitations imposed by the Telegram API. Teldrive is not responsible for any consequences arising from non-compliance with these API limits.You will be banned instantly if you misuse telegram API.

Visit https://teldrive-docs.pages.dev for setting up teldrive.

Recognitions

divyam234%2Fteldrive | Trendshift

Best Practices for Using Teldrive

Dos:

  • Follow Limits: Adhere to the limits imposed by Telegram servers to avoid account bans and automatic deletion of your channel.Your files will be removed from telegram servers if you try to abuse the service as most people have zero brains they will still do so good luck.
  • Responsible Storage: Be mindful of the content you store on Telegram. Utilize storage efficiently and only keep data that serves a purpose.

Don'ts:

  • Data Hoarding: Avoid excessive data hoarding, as it not only violates Telegram's terms.

By following these guidelines, you contribute to the responsible and effective use of Telegram, maintaining a fair and equitable environment for all users.

Contributing

Feel free to contribute to this project.See CONTRIBUTING.md for more information.

Donate

If you like this project small contribution would be appreciated Paypal.

Star History

Star History Chart