1
0
Fork 0
mirror of https://github.com/Chocobozzz/PeerTube.git synced 2025-10-06 03:50:26 +02:00

Fix infinite server crash on invalid zip import

This commit is contained in:
Chocobozzz 2025-04-03 10:27:18 +02:00
parent 0fc3f91d83
commit 71744313f0
No known key found for this signature in database
GPG key ID: 583A612D890159BE
3 changed files with 6 additions and 4 deletions

BIN
packages/tests/fixtures/export-crash.zip vendored Normal file

Binary file not shown.

View file

@ -3,7 +3,8 @@
import { HttpStatusCode } from '@peertube/peertube-models' import { HttpStatusCode } from '@peertube/peertube-models'
import { import {
cleanupTests, cleanupTests,
createSingleServer, PeerTubeServer, createSingleServer,
PeerTubeServer,
setAccessTokensToServers, setAccessTokensToServers,
waitJobs waitJobs
} from '@peertube/peertube-server-commands' } from '@peertube/peertube-server-commands'
@ -37,7 +38,6 @@ describe('Test user import API validators', function () {
}) })
describe('Request import', function () { describe('Request import', function () {
it('Should fail if import is disabled', async function () { it('Should fail if import is disabled', async function () {
await server.config.disableUserImport() await server.config.disableUserImport()
@ -121,7 +121,8 @@ describe('Test user import API validators', function () {
'export-bad-video.zip', 'export-bad-video.zip',
'export-without-videos.zip', 'export-without-videos.zip',
'export-bad-structure.zip', 'export-bad-structure.zip',
'export-bad-structure.zip' 'export-bad-structure.zip',
'export-crash.zip'
] ]
const tokens: string[] = [] const tokens: string[] = []
@ -141,7 +142,6 @@ describe('Test user import API validators', function () {
}) })
describe('Get latest import status', function () { describe('Get latest import status', function () {
it('Should fail without token', async function () { it('Should fail without token', async function () {
await server.userImports.getLatestImport({ userId, token: null, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 }) await server.userImports.getLatestImport({ userId, token: null, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
}) })

View file

@ -16,6 +16,8 @@ export async function unzip (source: string, destination: string) {
yauzl.open(source, { lazyEntries: true }, (err, zipFile) => { yauzl.open(source, { lazyEntries: true }, (err, zipFile) => {
if (err) return rej(err) if (err) return rej(err)
zipFile.on('error', err => rej(err))
zipFile.readEntry() zipFile.readEntry()
zipFile.on('entry', async entry => { zipFile.on('entry', async entry => {