Mercurial > mplayer.hg
comparison stream/stream_bd.c @ 31917:d0d09a75bb17
Check stream_read_line result instead of checking stream_eof,
checking stream_eof in the previous way would process the
last line twice or even use uninitialized data in case of
and empty file.
author | reimar |
---|---|
date | Sat, 21 Aug 2010 10:07:38 +0000 |
parents | 6b45e5fb9dc4 |
children | 4189a8951568 |
comparison
equal
deleted
inserted
replaced
31916:6b45e5fb9dc4 | 31917:d0d09a75bb17 |
---|---|
141 snprintf(dst + 2*i, 3, "%02"PRIX8, id[i]); | 141 snprintf(dst + 2*i, 3, "%02"PRIX8, id[i]); |
142 } | 142 } |
143 | 143 |
144 static int find_vuk(struct bd_priv *bd, const uint8_t discid[20]) | 144 static int find_vuk(struct bd_priv *bd, const uint8_t discid[20]) |
145 { | 145 { |
146 char line[1024]; | |
146 char filename[PATH_MAX]; | 147 char filename[PATH_MAX]; |
147 const char *home; | 148 const char *home; |
148 int vukfound = 0; | 149 int vukfound = 0; |
149 stream_t *file; | 150 stream_t *file; |
150 char idstr[ID_STR_LEN]; | 151 char idstr[ID_STR_LEN]; |
157 mp_msg(MSGT_OPEN,MSGL_ERR, | 158 mp_msg(MSGT_OPEN,MSGL_ERR, |
158 "Cannot open VUK database file %s\n", filename); | 159 "Cannot open VUK database file %s\n", filename); |
159 return 0; | 160 return 0; |
160 } | 161 } |
161 id2str(discid, 20, idstr); | 162 id2str(discid, 20, idstr); |
162 while (!stream_eof(file)) { | 163 while (stream_read_line(file, line, sizeof(line), 0)) { |
163 char line[1024]; | |
164 char *vst; | 164 char *vst; |
165 | 165 |
166 stream_read_line(file, line, sizeof(line), 0); | |
167 // file is built up this way: | 166 // file is built up this way: |
168 // DISCID = title | V | VUK | 167 // DISCID = title | V | VUK |
169 // or | 168 // or |
170 // DISCID = title | key-pair | 169 // DISCID = title | key-pair |
171 // key-pair = V | VUK | 170 // key-pair = V | VUK |