Processed: Re: Bug#1053483: Acknowledgement (tlsa can produce invalid records)

2023-10-04 Thread Debian Bug Tracking System
Processing control commands:

> forwarded -1 https://github.com/letoams/hash-slinger/issues/45
Bug #1053483 [hash-slinger] tlsa can produce invalid records
Set Bug forwarded-to-address to 
'https://github.com/letoams/hash-slinger/issues/45'.
> tags -1 +patch
Bug #1053483 [hash-slinger] tlsa can produce invalid records
Added tag(s) patch.

-- 
1053483: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1053483
Debian Bug Tracking System
Contact ow...@bugs.debian.org with problems



Bug#1053483: Acknowledgement (tlsa can produce invalid records)

2023-10-04 Thread Antoine Beaupré
Control: forwarded -1 https://github.com/letoams/hash-slinger/issues/45
Control: tags -1 +patch

I submitted this patch upstream to fix this issue:

https://github.com/letoams/hash-slinger/pull/46

Attached as well.

-- 
Antoine Beaupré
torproject.org system administration
>From e3bec6e2a6b1bda7c52b4c585474fd7cc23ab643 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Charaoui?= 
Date: Wed, 4 Oct 2023 22:05:26 -0400
Subject: [PATCH] fix generic TLSA record generation

It seems like the calculation for the TLSA record never really worked,
as we're doing float division here on the `len()` field. In our case,
that field returned `35.0` which is not valid in our environment.

Doing an integer division gives the correct result in most cases, I
believe.

Closes: #45
---
 tlsa | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tlsa b/tlsa
index cea7230..ec97150 100755
--- a/tlsa
+++ b/tlsa
@@ -513,7 +513,7 @@ class TLSARecord:
 	def getRecord(self, generic=False):
 		"""Returns the RR string of this TLSARecord, either in rfc (default) or generic format"""
 		if generic:
-			return '%s IN TYPE52 \# %s %s%s%s%s' % (self.name, (len(self.cert)/2)+3 , self._toHex(self.usage), self._toHex(self.selector), self._toHex(self.mtype), self.cert)
+			return '%s IN TYPE52 \# %s %s%s%s%s' % (self.name, (len(self.cert)//2)+3 , self._toHex(self.usage), self._toHex(self.selector), self._toHex(self.mtype), self.cert)
 		return '%s IN TLSA %s %s %s %s' % (self.name, self.usage, self.selector, self.mtype, self.cert)
 
 	def _toHex(self, val):
-- 
2.39.2