esim.saip.templates: Fix expand_default_value_pattern for length==0

The original code treated length==0 like length==None (unspecified),
which is wrong.

Change-Id: I39fa1e2b1b9d6d1c671ea37bdbec1d6f97e8a5e7
This commit is contained in:
Harald Welte
2024-09-01 19:53:00 +02:00
parent b22bab0b20
commit 6aabb92c38

View File

@@ -117,9 +117,9 @@ class FileTemplate:
def expand_default_value_pattern(self, length: Optional[int] = None) -> Optional[bytes]:
"""Expand the default value pattern to the specified length."""
if not length:
if length is None:
length = self._default_value_len()
if not length:
if length is None:
raise ValueError("%s does not have a default length" % self)
if not self.default_val:
return None