Skip to content

Commit b87bcc8

Browse files
committed
Fixed problem with decoding packed binary data
1 parent e00b686 commit b87bcc8

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

pygetdns_util.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -329,13 +329,13 @@ extensions_to_getdnsdict(PyDictObject *pydict)
329329
} else if (!strncmp(tmpoptionlistkey, "option_data", strlen("option_data"))) {
330330
option_data = (struct getdns_bindata *)malloc(sizeof(struct getdns_bindata));
331331
option_data->size = PyObject_Length(optiondictvalue);
332+
printf("XXX size is %d\n", (int)option_data->size);
332333
#if PY_MAJOR_VERSION >= 3
333-
/* This is almost certainly wrong */
334-
option_data->data = (uint8_t *)PyBytes_AsString(PyObject_Bytes(optiondictvalue));
334+
option_data->data = (uint8_t *)PyBytes_AS_STRING(optiondictvalue);
335335
#else
336-
/* ditto */
337-
option_data->data = (uint8_t *)PyString_AsString(PyObject_Bytes(optiondictvalue));
336+
option_data->data = (uint8_t *)PyString_AS_STRING(optiondictvalue);
338337
#endif
338+
339339
getdns_dict_set_bindata(tmpoptions_list_dict, "option_data", option_data);
340340
} else {
341341
PyErr_SetString(getdns_error, GETDNS_RETURN_EXTENSION_MISFORMAT_TEXT);

0 commit comments

Comments
 (0)