Adds METADATA and updates rune.c.

Test: builds
diff --git a/Android.mk b/Android.mk
new file mode 100644
index 0000000..887a1ab
--- /dev/null
+++ b/Android.mk
@@ -0,0 +1,37 @@
+LOCAL_PATH := $(call my-dir)
+
+utf_src := \
+    rune.c \
+    runestrcat.c \
+    runestrchr.c \
+    runestrcmp.c \
+    runestrcpy.c \
+    runestrdup.c \
+    runestrlen.c \
+    runestrecpy.c \
+    runestrncat.c \
+    runestrncmp.c \
+    runestrncpy.c \
+    runestrrchr.c \
+    runestrstr.c \
+    runetype.c \
+    utfecpy.c \
+    utflen.c \
+    utfnlen.c \
+    utfrrune.c \
+    utfrune.c \
+    utfutf.c
+
+utf_cflags := -Wall -Wno-missing-braces -Wno-parentheses -Wno-switch
+
+# We only build the static library at the moment.
+include $(CLEAR_VARS)
+
+LOCAL_MODULE := libutf
+LOCAL_SRC_FILES := $(utf_src)
+LOCAL_CFLAGS += -O3 $(utf_cflags)
+LOCAL_ARM_MODE := arm
+LOCAL_SDK_VERSION := 14
+
+include $(BUILD_STATIC_LIBRARY)
+
diff --git a/METADATA b/METADATA
new file mode 100644
index 0000000..6abebed
--- /dev/null
+++ b/METADATA
@@ -0,0 +1,15 @@
+name: "utf"
+description: "Library for handling UTF-8"
+
+third_party {
+  url {
+    type: HOMEPAGE
+    value: "http://swtch.com/plan9port/unix/"
+  }
+  url {
+    type: PIPER
+    value: "http://google3/third_party/libutf"
+  }
+  version: "1.1"
+  last_upgrade_date { year: 2018 month: 9 day: 19 }
+}
diff --git a/rune.c b/rune.c
index 65df3d3..92d9d2a 100644
--- a/rune.c
+++ b/rune.c
@@ -139,6 +139,8 @@
 		l = ((((((c << Bitx) | c1) << Bitx) | c2) << Bitx) | c3) & Rune4;
 		if (l <= Rune3)
 			goto bad;
+		if (l > Runemax)
+			goto bad;
 		*rune = l;
 		return 4;
 	}
@@ -222,6 +224,8 @@
 		l = ((((((c << Bitx) | c1) << Bitx) | c2) << Bitx) | c3) & Rune4;
 		if (l <= Rune3)
 			goto bad;
+		if (l > Runemax)
+			goto bad;
 		*rune = l;
 		return 4;
 	}
@@ -313,7 +317,8 @@
 int
 runenlen(const Rune *r, int nrune)
 {
-	int nb, c;
+	int nb;
+	ulong c;	/* Rune is signed, so use unsigned for range check. */
 
 	nb = 0;
 	while(nrune--) {
@@ -324,8 +329,10 @@
 			nb += 2;
 		else if (c <= Rune3)
 			nb += 3;
-		else /* assert(c <= Rune4) */ 
+		else if (c <= Runemax)
 			nb += 4;
+		else
+			nb += 3;	/* Runeerror = 0xFFFD, see runetochar */
 	}
 	return nb;
 }