Index: uspace/lib/c/generic/io/io.c
===================================================================
--- uspace/lib/c/generic/io/io.c	(revision 8fe46a0f40ff74ca91e8c0f7ece6d2b75eac9029)
+++ uspace/lib/c/generic/io/io.c	(revision 59f388a67f9319d79d123a42feecf8a6efba764e)
@@ -834,4 +834,8 @@
 off64_t ftell(FILE *stream)
 {
+	/* The native position is too large for the C99-ish interface. */
+	if (stream->pos - stream->ungetc_chars > INT64_MAX)
+		return EOF;
+
 	if (stream->error)
 		return EOF;
Index: uspace/lib/posix/source/sys/stat.c
===================================================================
--- uspace/lib/posix/source/sys/stat.c	(revision 8fe46a0f40ff74ca91e8c0f7ece6d2b75eac9029)
+++ uspace/lib/posix/source/sys/stat.c	(revision 59f388a67f9319d79d123a42feecf8a6efba764e)
@@ -49,6 +49,8 @@
  * @param dest POSIX stat struct.
  * @param src HelenOS stat struct.
+ *
+ * @return 0 on success, -1 on error.
  */
-static void stat_to_posix(struct posix_stat *dest, struct stat *src)
+static int stat_to_posix(struct posix_stat *dest, struct stat *src)
 {
 	memset(dest, 0, sizeof(struct posix_stat));
@@ -68,4 +70,11 @@
 	dest->st_nlink = src->lnkcnt;
 	dest->st_size = src->size;
+
+	if (src->size > INT64_MAX) {
+		errno = ERANGE;
+		return -1;
+	}
+
+	return 0;
 }
 
@@ -83,6 +92,5 @@
 	if (rc < 0)
 		return -1;
-	stat_to_posix(st, &hst);
-	return 0;
+	return stat_to_posix(st, &hst);
 }
 
@@ -113,6 +121,5 @@
 	if (rc < 0)
 		return -1;
-	stat_to_posix(st, &hst);
-	return 0;
+	return stat_to_posix(st, &hst);
 }
 
Index: uspace/lib/posix/source/unistd.c
===================================================================
--- uspace/lib/posix/source/unistd.c	(revision 8fe46a0f40ff74ca91e8c0f7ece6d2b75eac9029)
+++ uspace/lib/posix/source/unistd.c	(revision 59f388a67f9319d79d123a42feecf8a6efba764e)
@@ -245,4 +245,9 @@
 		break;
 	}
+	if (posix_pos[fildes] > INT64_MAX) {
+		/* The native width is too large for the POSIX interface. */
+		errno = ERANGE;
+		return -1;
+	}
 	return posix_pos[fildes];
 }
