summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDarren Salt <linux@youmustbejoking.demon.co.uk>2008-01-09 22:19:42 +0000
committerDarren Salt <linux@youmustbejoking.demon.co.uk>2008-01-09 22:19:42 +0000
commit2a9d1fe9f99cc2329a762f6e30a8ee0dc8e84014 (patch)
treee6de82180542abdc733fb874a5257c38c5fea8a5
parentc749ef5ef58af5f1a1856c802b0726bf6912601a (diff)
downloadxine-lib-2a9d1fe9f99cc2329a762f6e30a8ee0dc8e84014.tar.gz
xine-lib-2a9d1fe9f99cc2329a762f6e30a8ee0dc8e84014.tar.bz2
Fix a read-past-end bug in xine-lib's internal strtok_r replacement.
-rw-r--r--ChangeLog2
-rw-r--r--lib/strtok_r.c8
2 files changed, 6 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index b43e2b5d0..c2a6a74de 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,6 @@
xine-lib (1.1.9.1) (unreleased)
+ * Fix a read-past-end bug in xine-lib's internal strtok_r replacement.
+ (Only affects systems without strtok_r.)
xine-lib (1.1.9)
* Fix dvd://.../title[.chapter] handling (somewhat broken in 1.1.8).
diff --git a/lib/strtok_r.c b/lib/strtok_r.c
index cead029a2..8a5284a42 100644
--- a/lib/strtok_r.c
+++ b/lib/strtok_r.c
@@ -19,7 +19,7 @@ char *xine_private_strtok_r(char *s, const char *delim, char **ptrptr) {
else s = *ptrptr;
/* end of searching */
- if (!s || s == '\0') return NULL;
+ if (!s || !*s) return NULL;
/* cut the initial garbage */
cutlen = strspn(s, delim);
@@ -32,12 +32,12 @@ char *xine_private_strtok_r(char *s, const char *delim, char **ptrptr) {
}
next = s + toklen;
+ /* prepare next call */
+ *ptrptr = *next ? next + 1 : NULL;
+
/* cut current token */
*next = '\0';
- /* prepare next call */
- *ptrptr = next + 1;
-
/* return the token */
return s;
}