s4-scripting/devel: Fix str() vs bytes() issue in repl_cleartext_pwd.py
authorAndrew Bartlett <abartlet@samba.org>
Thu, 30 Mar 2023 01:29:22 +0000 (01:29 +0000)
committerAndrew Bartlett <abartlet@samba.org>
Thu, 16 Nov 2023 01:51:39 +0000 (01:51 +0000)
Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Reviewed-by: Joseph Sutton <josephsutton@catalyst.net.nz>
source4/scripting/devel/repl_cleartext_pwd.py

index e6b8ba615f1947877d6f69b801f133444c534159..7cb0af29c0b8c53d4cb28243404da0b081d0f36d 100755 (executable)
@@ -392,13 +392,14 @@ if __name__ == "__main__":
             # uint32_t utdv_blob_ofs
             store_hdr_len = 7 * 4
             dn_ofs = store_hdr_len
-            hwm_ofs = dn_ofs + len(dn)
+            dn_bytes = dn.encode('utf8')
+            hwm_ofs = dn_ofs + len(dn_bytes)
             utdv_ofs = hwm_ofs + len(store_hwm_blob)
             store_blob = struct.pack("<LLLLLLL", 1,
-                                     len(dn), dn_ofs,
+                                     len(dn_bytes), dn_ofs,
                                      len(store_hwm_blob), hwm_ofs,
                                      len(store_utdv_blob), utdv_ofs) + \
-                dn + store_hwm_blob + store_utdv_blob
+                dn_bytes + store_hwm_blob + store_utdv_blob
 
             tmp_file = "%s.tmp" % cookie_file
             f = open(tmp_file, 'wb')