libudfread | branch: master | Petri Hintukainen <[email protected]> | 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;

_______________________________________________
libbluray-devel mailing list
[email protected]
https://mailman.videolan.org/listinfo/libbluray-devel

Reply via email to