summaryrefslogtreecommitdiffstats
path: root/main/asterisk/ASTERISK-18994.patch
blob: 702e91375d123ac884c0df5a65361aea5d88f12b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
--- a/main/file.c.orig	2011-12-09 11:32:05.000000000 +0200
+++ b/main/file.c	2011-12-09 11:35:22.000000000 +0200
@@ -1005,6 +1005,7 @@
 	struct ast_filestream *fs;
 	struct ast_filestream *vfs=NULL;
 	char fmt[256];
+	off_t pos;
 	int seekattempt;
 	int res;
 
@@ -1017,12 +1018,14 @@
 	/* check to see if there is any data present (not a zero length file),
 	 * done this way because there is no where for ast_openstream_full to
 	 * return the file had no data. */
-	seekattempt = fseek(fs->f, -1, SEEK_END);
+	pos = ftello(fs->f);
+	seekattempt = fseeko(fs->f, -1, SEEK_END);
 	if (seekattempt && errno == EINVAL) {
 		/* Zero-length file, as opposed to a pipe */
 		return 0;
-	} else {
-		ast_seekstream(fs, 0, SEEK_SET);
+	}
+	if (seekattempt == 0) {
+		fseeko(fs->f, pos, SEEK_SET);
 	}
 
 	vfs = ast_openvstream(chan, filename, preflang);