Changeset 15e6f2c9d099fac8307a8e40055886e2f11de1d5
- Timestamp:
- 06/01/08 19:16:56
(3 months ago)
- Author:
- Rafaël Carré <funman@videolan.org>
- git-committer:
- Rafaël Carré <funman@videolan.org> 1212340616 +0200
- git-parent:
[53c74579305052334468d130a3f4bfcfc3757209]
- git-author:
- Rafaël Carré <funman@videolan.org> 1212323427 +0200
- Message:
Binary updates: support arbitrarily long descriptions
Note that an upper limit should be set anyway
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| rd666030 |
r15e6f2c |
|
| 68 | 68 | * * AKA "0.8.6d" or "0.9.0" |
|---|
| 69 | 69 | * Second line is an url of the binary for this last version |
|---|
| 70 | | * Third line is a description of the update (it MAY be extended to several lines, but for now it is only one line) |
|---|
| | 70 | * Remaining text is a required description of the update |
|---|
| 71 | 71 | */ |
|---|
| 72 | 72 | |
|---|
| … | … | |
| 1105 | 1105 | int i_revision = 0; |
|---|
| 1106 | 1106 | unsigned char extra; |
|---|
| 1107 | | char *psz_line = NULL; |
|---|
| 1108 | 1107 | char *psz_version_line = NULL; |
|---|
| 1109 | 1108 | |
|---|
| … | … | |
| 1116 | 1115 | } |
|---|
| 1117 | 1116 | |
|---|
| 1118 | | /* Try to read three lines */ |
|---|
| 1119 | | if( !( psz_line = stream_ReadLine( p_stream ) ) ) |
|---|
| | 1117 | /* Start reading the status file */ |
|---|
| | 1118 | if( !( psz_version_line = stream_ReadLine( p_stream ) ) ) |
|---|
| 1120 | 1119 | { |
|---|
| 1121 | 1120 | msg_Err( p_update->p_libvlc, "Update file %s is corrupted : missing version", |
|---|
| … | … | |
| 1124 | 1123 | } |
|---|
| 1125 | 1124 | |
|---|
| 1126 | | psz_version_line = psz_line; |
|---|
| 1127 | 1125 | /* first line : version number */ |
|---|
| 1128 | 1126 | p_update->release.extra = 0; |
|---|
| 1129 | | switch( sscanf( psz_line, "%i.%i.%i%c", &i_major, &i_minor, &i_revision, &extra ) ) |
|---|
| | 1127 | switch( sscanf( psz_version_line, "%i.%i.%i%c", |
|---|
| | 1128 | &i_major, &i_minor, &i_revision, &extra ) ) |
|---|
| 1130 | 1129 | { |
|---|
| 1131 | 1130 | case 4: |
|---|
| … | … | |
| 1141 | 1140 | } |
|---|
| 1142 | 1141 | |
|---|
| 1143 | | /* Second line : URL */ |
|---|
| 1144 | | if( !( psz_line = stream_ReadLine( p_stream ) ) ) |
|---|
| | 1142 | /* second line : URL */ |
|---|
| | 1143 | if( !( p_update->release.psz_url = stream_ReadLine( p_stream ) ) ) |
|---|
| 1145 | 1144 | { |
|---|
| 1146 | 1145 | msg_Err( p_update->p_libvlc, "Update file %s is corrupted : URL missing", |
|---|
| … | … | |
| 1148 | 1147 | goto error; |
|---|
| 1149 | 1148 | } |
|---|
| 1150 | | p_update->release.psz_url = psz_line; |
|---|
| 1151 | | |
|---|
| 1152 | | |
|---|
| 1153 | | /* Third line : description */ |
|---|
| 1154 | | if( !( psz_line = stream_ReadLine( p_stream ) ) ) |
|---|
| 1155 | | { |
|---|
| 1156 | | msg_Err( p_update->p_libvlc, "Update file %s is corrupted : description missing", |
|---|
| 1157 | | UPDATE_VLC_STATUS_URL ); |
|---|
| | 1149 | |
|---|
| | 1150 | /* Remaining data : description */ |
|---|
| | 1151 | int i_read = stream_Size( p_stream ) - stream_Tell( p_stream ); |
|---|
| | 1152 | if( i_read <= 0 ) |
|---|
| | 1153 | { |
|---|
| | 1154 | msg_Err( p_update->p_libvlc, |
|---|
| | 1155 | "Update file %s is corrupted: description missing", |
|---|
| | 1156 | UPDATE_VLC_STATUS_URL ); |
|---|
| 1158 | 1157 | goto error; |
|---|
| 1159 | 1158 | } |
|---|
| 1160 | | p_update->release.psz_desc = psz_line; |
|---|
| | 1159 | |
|---|
| | 1160 | p_update->release.psz_desc = (char*) malloc( i_read + 1 ); |
|---|
| | 1161 | if( !p_update->release.psz_desc ) |
|---|
| | 1162 | goto error; |
|---|
| | 1163 | |
|---|
| | 1164 | if( stream_Read( p_stream, p_update->release.psz_desc, i_read ) != i_read ) |
|---|
| | 1165 | { |
|---|
| | 1166 | msg_Err( p_update->p_libvlc, "Couldn't download update file %s", |
|---|
| | 1167 | UPDATE_VLC_STATUS_URL ); |
|---|
| | 1168 | goto error; |
|---|
| | 1169 | } |
|---|
| | 1170 | p_update->release.psz_desc[i_read] = '\0'; |
|---|
| 1161 | 1171 | |
|---|
| 1162 | 1172 | stream_Delete( p_stream ); |
|---|
| … | … | |
| 1245 | 1255 | gcry_md_putc( hd, '\r' ); |
|---|
| 1246 | 1256 | gcry_md_putc( hd, '\n' ); |
|---|
| 1247 | | gcry_md_write( hd, p_update->release.psz_desc, |
|---|
| 1248 | | strlen( p_update->release.psz_desc ) ); |
|---|
| 1249 | | if( sign.type == TEXT_SIGNATURE ) |
|---|
| 1250 | | gcry_md_putc( hd, '\r' ); |
|---|
| 1251 | | gcry_md_putc( hd, '\n' ); |
|---|
| 1252 | | |
|---|
| | 1257 | |
|---|
| | 1258 | char *psz_desc = p_update->release.psz_desc; |
|---|
| | 1259 | while( *psz_desc ) |
|---|
| | 1260 | { |
|---|
| | 1261 | size_t i_len = strcspn( psz_desc, "\r\n" ); |
|---|
| | 1262 | if( !i_len ) |
|---|
| | 1263 | break; |
|---|
| | 1264 | |
|---|
| | 1265 | gcry_md_write( hd, psz_desc, i_len ); |
|---|
| | 1266 | if( sign.type == TEXT_SIGNATURE ) |
|---|
| | 1267 | gcry_md_putc( hd, '\r' ); |
|---|
| | 1268 | gcry_md_putc( hd, '\n' ); |
|---|
| | 1269 | |
|---|
| | 1270 | psz_desc += i_len; |
|---|
| | 1271 | while( *psz_desc == '\r' || *psz_desc == '\n' ) |
|---|
| | 1272 | psz_desc++; |
|---|
| | 1273 | } |
|---|
| 1253 | 1274 | |
|---|
| 1254 | 1275 | if( sign.version == 3 ) |
|---|