Skip to content

Commit

Permalink
fix: error on reading malformed package
Browse files Browse the repository at this point in the history
  • Loading branch information
cpvalente committed Feb 17, 2025
1 parent 8ac5c0a commit 3d40e31
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions apps/server/src/adapters/OscAdapter.ts
Original file line number Diff line number Diff line change
@@ -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;

Expand All @@ -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`);
Expand Down

0 comments on commit 3d40e31

Please sign in to comment.