summaryrefslogtreecommitdiff
path: root/plugins/pychrysa/analysis/content.c
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2015-11-25 23:26:53 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2015-11-25 23:26:53 (GMT)
commit545d0490f6fbb397da66410f534670c52bfcc5da (patch)
treeb6923de79a4b406e51b906b76a737d93ea74b73c /plugins/pychrysa/analysis/content.c
parent355a7140932b77d351bc6ddd965608b0011af855 (diff)
Implemented restricted contents and created test cases.
git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@608 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a
Diffstat (limited to 'plugins/pychrysa/analysis/content.c')
-rw-r--r--plugins/pychrysa/analysis/content.c27
1 files changed, 23 insertions, 4 deletions
diff --git a/plugins/pychrysa/analysis/content.c b/plugins/pychrysa/analysis/content.c
index bd25589..00265e3 100644
--- a/plugins/pychrysa/analysis/content.c
+++ b/plugins/pychrysa/analysis/content.c
@@ -29,6 +29,9 @@
#include <pygobject.h>
+#include <i18n.h>
+
+
#include <analysis/content.h>
#include <common/endianness.h>
@@ -154,7 +157,11 @@ static PyObject *py_binary_content_read_u8(PyObject *self, PyObject *args)
assert(addr != NULL);
status = g_binary_content_read_u8(content, addr, &val);
- if (!status) return NULL;
+ if (!status)
+ {
+ PyErr_SetString(PyExc_Exception, _("Invalid read access."));
+ return NULL;
+ }
result = PyBytes_FromStringAndSize((char *)&val, 1);
@@ -197,7 +204,11 @@ static PyObject *py_binary_content_read_u16(PyObject *self, PyObject *args)
assert(addr != NULL);
status = g_binary_content_read_u16(content, addr, endianness, &val);
- if (!status) return NULL;
+ if (!status)
+ {
+ PyErr_SetString(PyExc_Exception, _("Invalid read access."));
+ return NULL;
+ }
result = PyBytes_FromStringAndSize((char *)&val, 2);
@@ -239,7 +250,11 @@ static PyObject *py_binary_content_read_u32(PyObject *self, PyObject *args)
assert(addr != NULL);
status = g_binary_content_read_u32(content, addr, endianness, &val);
- if (!status) return NULL;
+ if (!status)
+ {
+ PyErr_SetString(PyExc_Exception, _("Invalid read access."));
+ return NULL;
+ }
result = PyBytes_FromStringAndSize((char *)&val, 4);
@@ -281,7 +296,11 @@ static PyObject *py_binary_content_read_u64(PyObject *self, PyObject *args)
assert(addr != NULL);
status = g_binary_content_read_u64(content, addr, endianness, &val);
- if (!status) return NULL;
+ if (!status)
+ {
+ PyErr_SetString(PyExc_Exception, _("Invalid read access."));
+ return NULL;
+ }
result = PyBytes_FromStringAndSize((char *)&val, 8);