fix: error on reading malformed package

This commit is contained in:
Carlos Valente
2025-02-17 12:51:28 +01:00
committed by Carlos Valente
parent 8ac5c0a9a2
commit 3d40e31730
+12 -4
View File
@@ -1,14 +1,15 @@
import { LogOrigin } from 'ontime-types';
import { fromBuffer } from 'osc-min';
import { fromBuffer, type OscPacketOutput } from 'osc-min';
import * as dgram from 'node:dgram';
import type { IAdapter } from './IAdapter.js';
import { logger } from '../classes/Logger.js';
import { integrationPayloadFromPath } from './utils/parse.js';
import { dispatchFromAdapter } from '../api-integration/integration.controller.js';
import { isOntimeCloud } from '../externals.js';
import { integrationPayloadFromPath } from './utils/parse.js';
import type { IAdapter } from './IAdapter.js';
class OscServer implements IAdapter {
private udpSocket: dgram.Socket | null = null;
@@ -27,7 +28,14 @@ class OscServer implements IAdapter {
// params: used to create a nested object to patch with
// args: extra data, only used on some API entries
const msg = fromBuffer(buf);
let msg: OscPacketOutput;
try {
msg = fromBuffer(buf);
} catch (_e) {
logger.error(LogOrigin.Rx, 'OSC IN: Received invalid OSC message');
return;
}
if (msg.oscType === 'bundle') {
//TODO: manage bundles
logger.error(LogOrigin.Rx, `OSC IN: We don't take bundles`);