Skip to content

opc_da: OpcDaFack(selack=None) now builds silently as zeros instead of failing (since #5095) #5201

Description

@IcantFind-a-username

Brief description

Since #5095 ("opc_da: fix STDOBJREF IPID and Fack selack field types"), building an OpcDaFack with selack=None
succeeds and serializes the entry as zero bytes. Before #5095 the build failed with
While building field 'selack': cannot convert 'NoneType' object to bytes.

This is an edge case and may well be acceptable; reporting it in case the silent zero value is not intended, since
selack is a list of integers and None is not a valid entry.

Scapy version

master at c5e9a5b (2026-09-26)

Python version

3.10

Operating system

Linux (Docker)

Additional environment information

No response

How to reproduce

from scapy.contrib.opc_da import OpcDaFack
from scapy.all import raw

pkt = OpcDaFack(selack=None)
print(pkt.selack, pkt.selackLen)   # [None] 0
print(raw(pkt).hex())

Actual result

[None] 0
000000000000000000000000000000000000000000

selackLen stays 0, but the packet is 4 bytes longer than raw(OpcDaFack()) (17 bytes): the None entry is written as a zero integer, so the length field and the list disagree.

Expected result

An error for the invalid None entry, as before, or at least a length field consistent with the list.

Related resources

#5095 (cc @mmadersbacher). Found by differential testing of recent pull requests and reproduced by hand on current master.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions