[libbluray-devel] dstring length can't be < 0

Petri Hintukainen git at videolan.org
Mon Jun 20 17:14:54 CEST 2016


libudfread | branch: master | Petri Hintukainen <phintuka at gmail.com> | Sat Jun 18 15:08:23 2016 +0300| [0d7697f9e65160f0aaeeedee6674aa48068d7fe1] | committer: Petri Hintukainen

dstring length can't be < 0

> http://git.videolan.org/gitweb.cgi/libudfread.git/?a=commit;h=0d7697f9e65160f0aaeeedee6674aa48068d7fe1
---

 src/ecma167.c |   15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/src/ecma167.c b/src/ecma167.c
index ff4d791..571253d 100644
--- a/src/ecma167.c
+++ b/src/ecma167.c
@@ -37,11 +37,18 @@
  */
 
 /* fixed-length dstring, ECMA 1/7.2.12 */
-static int _decode_dstring(const uint8_t *p, int field_length, uint8_t *str)
+static size_t _decode_dstring(const uint8_t *p, size_t field_length, uint8_t *str)
 {
-    int length = _get_u8(p + field_length - 1);
-    if (length > field_length - 1) {
-        length = field_length - 1;
+    size_t length;
+
+    if (field_length < 1) {
+        return 0;
+    }
+    field_length--;
+
+    length = _get_u8(p + field_length);
+    if (length > field_length) {
+        length = field_length;
     }
     memcpy(str, p, length);
     return length;



More information about the libbluray-devel mailing list