]> git.sesse.net Git - vlc/blob - src/misc/update.c
Revert "update: allow update_Download to accept: directory, filename, NULL"
[vlc] / src / misc / update.c
1 /*****************************************************************************
2  * update.c: VLC update checking and downloading
3  *****************************************************************************
4  * Copyright © 2005-2008 the VideoLAN team
5  * $Id$
6  *
7  * Authors: Antoine Cellerier <dionoea -at- videolan -dot- org>
8  *          Rémi Duraffort <ivoire at via.ecp.fr>
9             Rafaël Carré <funman@videolanorg>
10  *
11  * This program is free software; you can redistribute it and/or modify
12  * it under the terms of the GNU General Public License as published by
13  * the Free Software Foundation; either release 2 of the License, or
14  * (at your option) any later release.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License
22  * along with this program; if not, write to the Free Software
23  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
24  *****************************************************************************/
25
26 /**
27  *   \file
28  *   This file contains functions related to VLC update management
29  */
30
31 /*****************************************************************************
32  * Preamble
33  *****************************************************************************/
34
35 #ifdef HAVE_CONFIG_H
36 # include "config.h"
37 #endif
38
39 #include <vlc_common.h>
40 #include <vlc_update.h>
41
42 #ifdef UPDATE_CHECK
43
44 #include <assert.h>
45
46 #include <vlc_pgpkey.h>
47 #include <vlc_stream.h>
48 #include <vlc_strings.h>
49 #include <vlc_charset.h>
50 #include <vlc_dialog.h>
51
52 #include <gcrypt.h>
53 #include <vlc_gcrypt.h>
54
55 #include "update.h"
56 #include "../libvlc.h"
57
58 /*****************************************************************************
59  * Misc defines
60  *****************************************************************************/
61
62 /*
63  * Here is the format of these "status files" :
64  * First line is the last version: "X.Y.Ze" where:
65  *      * X is the major number
66  *      * Y is the minor number
67  *      * Z is the revision number
68  *      * e is an OPTIONAL extra letter
69  *      * AKA "0.8.6d" or "0.9.0"
70  * Second line is an url of the binary for this last version
71  * Remaining text is a required description of the update
72  */
73
74 #if defined( UNDER_CE )
75 #   define UPDATE_VLC_STATUS_URL "http://update.videolan.org/vlc/status-ce"
76 #elif defined( WIN32 )
77 #   define UPDATE_VLC_STATUS_URL "http://update.videolan.org/vlc/status-win-x86"
78 #elif defined( __APPLE__ )
79 #   if defined( __powerpc__ ) || defined( __ppc__ ) || defined( __ppc64__ )
80 #       define UPDATE_VLC_STATUS_URL "http://update.videolan.org/vlc/status-mac-ppc"
81 #   else
82 #       define UPDATE_VLC_STATUS_URL "http://update.videolan.org/vlc/status-mac-x86"
83 #   endif
84 #elif defined( SYS_BEOS )
85 #       define UPDATE_VLC_STATUS_URL "http://update.videolan.org/vlc/status-beos-x86"
86 #else
87 #   define UPDATE_VLC_STATUS_URL "http://update.videolan.org/vlc/status"
88 #endif
89
90
91 /*****************************************************************************
92  * Local Prototypes
93  *****************************************************************************/
94 static void EmptyRelease( update_t *p_update );
95 static bool GetUpdateFile( update_t *p_update );
96 static char * size_str( long int l_size );
97
98
99
100 /*****************************************************************************
101  * Update_t functions
102  *****************************************************************************/
103
104 /**
105  * Create a new update VLC struct
106  *
107  * \param p_this the calling vlc_object
108  * \return pointer to new update_t or NULL
109  */
110 update_t *__update_New( vlc_object_t *p_this )
111 {
112     update_t *p_update;
113     assert( p_this );
114
115     p_update = (update_t *)malloc( sizeof( update_t ) );
116     if( !p_update ) return NULL;
117
118     vlc_mutex_init( &p_update->lock );
119
120     p_update->p_libvlc = p_this->p_libvlc;
121
122     p_update->release.psz_url = NULL;
123     p_update->release.psz_desc = NULL;
124
125     p_update->p_download = NULL;
126     p_update->p_check = NULL;
127
128     p_update->p_pkey = NULL;
129     vlc_gcrypt_init();
130
131     return p_update;
132 }
133
134 /**
135  * Delete an update_t struct
136  *
137  * \param p_update update_t* pointer
138  * \return nothing
139  */
140 void update_Delete( update_t *p_update )
141 {
142     assert( p_update );
143
144     if( p_update->p_check )
145     {
146         assert( !p_update->p_download );
147         vlc_object_kill( p_update->p_check );
148         vlc_thread_join( p_update->p_check );
149         vlc_object_release( p_update->p_check );
150     }
151     else if( p_update->p_download )
152     {
153         vlc_object_kill( p_update->p_download );
154         vlc_thread_join( p_update->p_download );
155         vlc_object_release( p_update->p_download );
156     }
157
158     vlc_mutex_destroy( &p_update->lock );
159
160     free( p_update->release.psz_url );
161     free( p_update->release.psz_desc );
162     free( p_update->p_pkey );
163
164     free( p_update );
165 }
166
167 /**
168  * Empty the release struct
169  *
170  * \param p_update update_t* pointer
171  * \return nothing
172  */
173 static void EmptyRelease( update_t *p_update )
174 {
175     p_update->release.i_major = 0;
176     p_update->release.i_minor = 0;
177     p_update->release.i_revision = 0;
178
179     FREENULL( p_update->release.psz_url );
180     FREENULL( p_update->release.psz_desc );
181 }
182
183 /**
184  * Get the update file and parse it
185  * p_update has to be locked when calling this function
186  *
187  * \param p_update pointer to update struct
188  * \return true if the update is valid and authenticated
189  */
190 static bool GetUpdateFile( update_t *p_update )
191 {
192     stream_t *p_stream = NULL;
193     int i_major = 0;
194     int i_minor = 0;
195     int i_revision = 0;
196     unsigned char extra;
197     char *psz_version_line = NULL;
198
199     p_stream = stream_UrlNew( p_update->p_libvlc, UPDATE_VLC_STATUS_URL );
200     if( !p_stream )
201     {
202         msg_Err( p_update->p_libvlc, "Failed to open %s for reading",
203                  UPDATE_VLC_STATUS_URL );
204         goto error;
205     }
206
207     /* Start reading the status file */
208     if( !( psz_version_line = stream_ReadLine( p_stream ) ) )
209     {
210         msg_Err( p_update->p_libvlc, "Update file %s is corrupted : missing version",
211                  UPDATE_VLC_STATUS_URL );
212         goto error;
213     }
214
215     /* first line : version number */
216     p_update->release.extra = 0;
217     switch( sscanf( psz_version_line, "%i.%i.%i%c",
218                     &i_major, &i_minor, &i_revision, &extra ) )
219     {
220         case 4:
221             p_update->release.extra = extra;
222         case 3:
223             p_update->release.i_major = i_major;
224             p_update->release.i_minor = i_minor;
225             p_update->release.i_revision = i_revision;
226             break;
227         default:
228             msg_Err( p_update->p_libvlc, "Update version false formated" );
229             goto error;
230     }
231
232     /* second line : URL */
233     if( !( p_update->release.psz_url = stream_ReadLine( p_stream ) ) )
234     {
235         msg_Err( p_update->p_libvlc, "Update file %s is corrupted : URL missing",
236                  UPDATE_VLC_STATUS_URL );
237         goto error;
238     }
239
240     /* Remaining data : description */
241     int i_read = stream_Size( p_stream ) - stream_Tell( p_stream );
242     if( i_read <= 0 )
243     {
244         msg_Err( p_update->p_libvlc,
245                 "Update file %s is corrupted: description missing",
246                 UPDATE_VLC_STATUS_URL );
247         goto error;
248     }
249
250     p_update->release.psz_desc = (char*) malloc( i_read + 1 );
251     if( !p_update->release.psz_desc )
252         goto error;
253
254     if( stream_Read( p_stream, p_update->release.psz_desc, i_read ) != i_read )
255     {
256         msg_Err( p_update->p_libvlc, "Couldn't download update file %s",
257                 UPDATE_VLC_STATUS_URL );
258         goto error;
259     }
260     p_update->release.psz_desc[i_read] = '\0';
261
262     stream_Delete( p_stream );
263     p_stream = NULL;
264
265     /* Now that we know the status is valid, we must download its signature
266      * to authenticate it */
267     signature_packet_t sign;
268     if( download_signature( VLC_OBJECT( p_update->p_libvlc ), &sign,
269             UPDATE_VLC_STATUS_URL ) != VLC_SUCCESS )
270     {
271         msg_Err( p_update->p_libvlc, "Couldn't download signature of status file" );
272         goto error;
273     }
274
275     if( sign.type != BINARY_SIGNATURE && sign.type != TEXT_SIGNATURE )
276     {
277         msg_Err( p_update->p_libvlc, "Invalid signature type" );
278         goto error;
279     }
280
281     p_update->p_pkey = (public_key_t*)malloc( sizeof( public_key_t ) );
282     if( !p_update->p_pkey )
283         goto error;
284
285     if( parse_public_key( videolan_public_key, sizeof( videolan_public_key ),
286                         p_update->p_pkey, NULL ) != VLC_SUCCESS )
287     {
288         msg_Err( p_update->p_libvlc, "Couldn't parse embedded public key, something went really wrong..." );
289         FREENULL( p_update->p_pkey );
290         goto error;
291     }
292
293     memcpy( p_update->p_pkey->longid, videolan_public_key_longid, 8 );
294
295     if( memcmp( sign.issuer_longid, p_update->p_pkey->longid , 8 ) != 0 )
296     {
297         msg_Dbg( p_update->p_libvlc, "Need to download the GPG key" );
298         public_key_t *p_new_pkey = download_key(
299                 VLC_OBJECT(p_update->p_libvlc),
300                 sign.issuer_longid, videolan_public_key_longid );
301         if( !p_new_pkey )
302         {
303             msg_Err( p_update->p_libvlc, "Couldn't download GPG key" );
304             FREENULL( p_update->p_pkey );
305             goto error;
306         }
307
308         uint8_t *p_hash = hash_sha1_from_public_key( p_new_pkey );
309         if( !p_hash )
310         {
311             msg_Err( p_update->p_libvlc, "Failed to hash signature" );
312             free( p_new_pkey );
313             FREENULL( p_update->p_pkey );
314             goto error;
315         }
316
317         if( verify_signature( p_new_pkey->sig.r, p_new_pkey->sig.s,
318                     &p_update->p_pkey->key, p_hash ) == VLC_SUCCESS )
319         {
320             free( p_hash );
321             msg_Info( p_update->p_libvlc, "Key authenticated" );
322             free( p_update->p_pkey );
323             p_update->p_pkey = p_new_pkey;
324         }
325         else
326         {
327             free( p_hash );
328             msg_Err( p_update->p_libvlc, "Key signature invalid !\n" );
329             goto error;
330         }
331     }
332
333     /* FIXME : read the status file all at once instead of line per line */
334     char *psz_text;
335     if( asprintf( &psz_text, "%s\n%s\n%s", psz_version_line,
336                 p_update->release.psz_url, p_update->release.psz_desc ) == -1 )
337     {
338         goto error;
339     }
340     FREENULL( psz_version_line );
341
342     uint8_t *p_hash = hash_sha1_from_text( psz_text, &sign );
343     if( !p_hash )
344     {
345         msg_Warn( p_update->p_libvlc, "Can't compute SHA1 hash for status file" );
346         goto error;
347     }
348
349     else if( p_hash[0] != sign.hash_verification[0] ||
350         p_hash[1] != sign.hash_verification[1] )
351     {
352         msg_Warn( p_update->p_libvlc, "Bad SHA1 hash for status file" );
353         goto error;
354     }
355
356     else if( verify_signature( sign.r, sign.s, &p_update->p_pkey->key, p_hash )
357             != VLC_SUCCESS )
358     {
359         msg_Err( p_update->p_libvlc, "BAD SIGNATURE for status file" );
360         goto error;
361     }
362
363     else
364     {
365         msg_Info( p_update->p_libvlc, "Status file authenticated" );
366         return true;
367     }
368
369 error:
370     if( p_stream )
371         stream_Delete( p_stream );
372     free( psz_version_line );
373     return false;
374 }
375
376 static void* update_CheckReal( vlc_object_t *p_this );
377
378 /**
379  * Check for updates
380  *
381  * \param p_update pointer to update struct
382  * \param pf_callback pointer to a function to call when the update_check is finished
383  * \param p_data pointer to some datas to give to the callback
384  * \returns nothing
385  */
386 void update_Check( update_t *p_update, void (*pf_callback)( void*, bool ), void *p_data )
387 {
388     assert( p_update );
389
390     // If the object already exist, destroy it
391     if( p_update->p_check )
392     {
393         vlc_object_kill( p_update->p_check );
394         vlc_thread_join( p_update->p_check );
395         vlc_object_release( p_update->p_check );
396     }
397
398     update_check_thread_t *p_uct =
399         vlc_custom_create( p_update->p_libvlc, sizeof( *p_uct ),
400                            VLC_OBJECT_GENERIC, "update check" );
401     if( !p_uct ) return;
402
403     p_uct->p_update = p_update;
404     p_update->p_check = p_uct;
405     p_uct->pf_callback = pf_callback;
406     p_uct->p_data = p_data;
407
408     vlc_thread_create( p_uct, "check for update", update_CheckReal,
409                        VLC_THREAD_PRIORITY_LOW );
410 }
411
412 void* update_CheckReal( vlc_object_t* p_this )
413 {
414     update_check_thread_t *p_uct = (update_check_thread_t *)p_this;
415     bool b_ret;
416     int canc;
417
418     canc = vlc_savecancel ();
419     vlc_mutex_lock( &p_uct->p_update->lock );
420
421     EmptyRelease( p_uct->p_update );
422     b_ret = GetUpdateFile( p_uct->p_update );
423     vlc_mutex_unlock( &p_uct->p_update->lock );
424
425     if( p_uct->pf_callback )
426         (p_uct->pf_callback)( p_uct->p_data, b_ret );
427
428     vlc_restorecancel (canc);
429     return NULL;
430 }
431
432 /**
433  * Compare a given release's version number to the current VLC's one
434  *
435  * \param p_update structure
436  * \return true if we have to upgrade to the given version to be up to date
437  */
438 static bool is_strictly_greater( int * a, int * b, int n)
439 {
440     if( n <= 0 ) return false;
441     if(a[0] > b[0] ) return true;
442     if(a[0] == b[0] ) return is_strictly_greater( a+1, b+1, n-1 );
443     /* a[0] < b[0] */ return false;
444 }
445
446 bool update_NeedUpgrade( update_t *p_update )
447 {
448     assert( p_update );
449
450     int current_version[] = {
451         *PACKAGE_VERSION_MAJOR - '0',
452         *PACKAGE_VERSION_MINOR - '0',
453         *PACKAGE_VERSION_REVISION - '0',
454         *PACKAGE_VERSION_EXTRA
455     };
456     int latest_version[] = {
457         p_update->release.i_major,
458         p_update->release.i_minor,
459         p_update->release.i_revision,
460         p_update->release.extra
461     };
462
463     return is_strictly_greater( latest_version, current_version, 4 );
464 }
465
466 /**
467  * Convert a long int size in bytes to a string
468  *
469  * \param l_size the size in bytes
470  * \return the size as a string
471  */
472 static char *size_str( long int l_size )
473 {
474     char *psz_tmp = NULL;
475     int i_retval = 0;
476     if( l_size >> 30 )
477         i_retval = asprintf( &psz_tmp, _("%.1f GB"), (float)l_size/(1<<30) );
478     else if( l_size >> 20 )
479         i_retval = asprintf( &psz_tmp, _("%.1f MB"), (float)l_size/(1<<20) );
480     else if( l_size >> 10 )
481         i_retval = asprintf( &psz_tmp, _("%.1f kB"), (float)l_size/(1<<10) );
482     else
483         i_retval = asprintf( &psz_tmp, _("%ld B"), l_size );
484
485     return i_retval == -1 ? NULL : psz_tmp;
486 }
487
488 static void* update_DownloadReal( vlc_object_t *p_this );
489
490 /**
491  * Download the file given in the update_t
492  *
493  * \param p_update structure
494  * \param dir to store the download file
495  * \return nothing
496  */
497 void update_Download( update_t *p_update, const char *psz_destdir )
498 {
499     assert( p_update );
500
501     // If the object already exist, destroy it
502     if( p_update->p_download )
503     {
504         vlc_object_kill( p_update->p_download );
505         vlc_thread_join( p_update->p_download );
506         vlc_object_release( p_update->p_download );
507     }
508
509     update_download_thread_t *p_udt =
510         vlc_custom_create( p_update->p_libvlc, sizeof( *p_udt ),
511                            VLC_OBJECT_GENERIC, "update download" );
512     if( !p_udt )
513         return;
514
515     p_udt->p_update = p_update;
516     p_update->p_download = p_udt;
517     p_udt->psz_destdir = psz_destdir ? strdup( psz_destdir ) : NULL;
518
519     vlc_thread_create( p_udt, "download update", update_DownloadReal,
520                        VLC_THREAD_PRIORITY_LOW );
521 }
522
523 static void* update_DownloadReal( vlc_object_t *p_this )
524 {
525     update_download_thread_t *p_udt = (update_download_thread_t *)p_this;
526     dialog_progress_bar_t *p_progress = NULL;
527     long int l_size;
528     long int l_downloaded = 0;
529     float f_progress;
530     char *psz_status = NULL;
531     char *psz_downloaded = NULL;
532     char *psz_size = NULL;
533     char *psz_destfile = NULL;
534     char *psz_tmpdestfile = NULL;
535
536     FILE *p_file = NULL;
537     stream_t *p_stream = NULL;
538     void* p_buffer = NULL;
539     int i_read;
540     int canc;
541
542     update_t *p_update = p_udt->p_update;
543     char *psz_destdir = p_udt->psz_destdir;
544
545     msg_Dbg( p_udt, "Opening Stream '%s'", p_update->release.psz_url );
546     canc = vlc_savecancel ();
547
548     /* Open the stream */
549     p_stream = stream_UrlNew( p_udt, p_update->release.psz_url );
550     if( !p_stream )
551     {
552         msg_Err( p_udt, "Failed to open %s for reading", p_update->release.psz_url );
553         goto end;
554     }
555
556     /* Get the stream size */
557     l_size = stream_Size( p_stream );
558
559     /* Get the file name and open it*/
560     psz_tmpdestfile = strrchr( p_update->release.psz_url, '/' );
561     if( !psz_tmpdestfile )
562     {
563         msg_Err( p_udt, "The URL %s is badly formated",
564                  p_update->release.psz_url );
565         goto end;
566     }
567     psz_tmpdestfile++;
568     if( asprintf( &psz_destfile, "%s%s", psz_destdir, psz_tmpdestfile ) == -1 )
569         goto end;
570
571     p_file = utf8_fopen( psz_destfile, "w" );
572     if( !p_file )
573     {
574         msg_Err( p_udt, "Failed to open %s for writing", psz_destfile );
575         dialog_FatalWait( p_udt, _("Saving file failed"),
576             _("Failed to open \"%s\" for writing"),
577              psz_destfile );
578         goto end;
579     }
580
581     /* Create a buffer and fill it with the downloaded file */
582     p_buffer = (void *)malloc( 1 << 10 );
583     if( !p_buffer )
584     {
585         msg_Err( p_udt, "Can't malloc (1 << 10) bytes! download cancelled." );
586         goto end;
587     }
588
589     msg_Dbg( p_udt, "Downloading Stream '%s'", p_update->release.psz_url );
590
591     psz_size = size_str( l_size );
592     if( asprintf( &psz_status, _("%s\nDownloading... %s/%s %.1f%% done"),
593         p_update->release.psz_url, "0.0", psz_size, 0.0 ) != -1 )
594     {
595         p_progress = dialog_ProgressCreate( p_udt, _( "Downloading ..."),
596                                             psz_status, _("Cancel") );
597         free( psz_status );
598     }
599
600     while( vlc_object_alive( p_udt ) &&
601            ( i_read = stream_Read( p_stream, p_buffer, 1 << 10 ) ) &&
602            !dialog_ProgressCancelled( p_progress ) )
603     {
604         if( fwrite( p_buffer, i_read, 1, p_file ) < 1 )
605         {
606             msg_Err( p_udt, "Failed to write into %s", psz_destfile );
607             break;
608         }
609
610         l_downloaded += i_read;
611         psz_downloaded = size_str( l_downloaded );
612         f_progress = (float)l_downloaded/(float)l_size;
613
614         if( asprintf( &psz_status, _( "%s\nDownloading... %s/%s %.1f%% done" ),
615                       p_update->release.psz_url, psz_downloaded, psz_size,
616                       f_progress ) != -1 )
617         {
618             dialog_ProgressSet( p_progress, psz_status, f_progress );
619             free( psz_status );
620         }
621         free( psz_downloaded );
622     }
623
624     /* Finish the progress bar or delete the file if the user had canceled */
625     fclose( p_file );
626     p_file = NULL;
627
628     if( vlc_object_alive( p_udt ) &&
629         !dialog_ProgressCancelled( p_progress ) )
630     {
631         if( asprintf( &psz_status, _("%s\nDone %s (100.0%%)"),
632             p_update->release.psz_url, psz_size ) != -1 )
633         {
634             dialog_ProgressDestroy( p_progress );
635             p_progress = NULL;
636             free( psz_status );
637         }
638     }
639     else
640     {
641         utf8_unlink( psz_destfile );
642         goto end;
643     }
644
645     signature_packet_t sign;
646     if( download_signature( VLC_OBJECT( p_udt ), &sign,
647             p_update->release.psz_url ) != VLC_SUCCESS )
648     {
649         utf8_unlink( psz_destfile );
650
651         dialog_FatalWait( p_udt, _("File could not be verified"),
652             _("It was not possible to download a cryptographic signature for "
653               "the downloaded file \"%s\". Thus, it was deleted."),
654             psz_destfile );
655         msg_Err( p_udt, "Couldn't download signature of downloaded file" );
656         goto end;
657     }
658
659     if( memcmp( sign.issuer_longid, p_update->p_pkey->longid, 8 ) )
660     {
661         utf8_unlink( psz_destfile );
662         msg_Err( p_udt, "Invalid signature issuer" );
663         dialog_FatalWait( p_udt, _("Invalid signature"),
664             _("The cryptographic signature for the downloaded file \"%s\" was "
665               "invalid and could not be used to securely verify it. Thus, the "
666               "file was deleted."),
667             psz_destfile );
668         goto end;
669     }
670
671     if( sign.type != BINARY_SIGNATURE )
672     {
673         utf8_unlink( psz_destfile );
674         msg_Err( p_udt, "Invalid signature type" );
675         dialog_FatalWait( p_udt, _("Invalid signature"),
676             _("The cryptographic signature for the downloaded file \"%s\" was "
677               "invalid and could not be used to securely verify it. Thus, the "
678               "file was deleted."),
679             psz_destfile );
680         goto end;
681     }
682
683     uint8_t *p_hash = hash_sha1_from_file( psz_destfile, &sign );
684     if( !p_hash )
685     {
686         msg_Err( p_udt, "Unable to hash %s", psz_destfile );
687         utf8_unlink( psz_destfile );
688         dialog_FatalWait( p_udt, _("File not verifiable"),
689             _("It was not possible to securely verify the downloaded file"
690               " \"%s\". Thus, it was deleted."),
691             psz_destfile );
692
693         goto end;
694     }
695
696     if( p_hash[0] != sign.hash_verification[0] ||
697         p_hash[1] != sign.hash_verification[1] )
698     {
699         utf8_unlink( psz_destfile );
700         dialog_FatalWait( p_udt, _("File corrupted"),
701             _("Downloaded file \"%s\" was corrupted. Thus, it was deleted."),
702              psz_destfile );
703         msg_Err( p_udt, "Bad SHA1 hash for %s", psz_destfile );
704         free( p_hash );
705         goto end;
706     }
707
708     if( verify_signature( sign.r, sign.s, &p_update->p_pkey->key, p_hash )
709             != VLC_SUCCESS )
710     {
711         utf8_unlink( psz_destfile );
712         dialog_FatalWait( p_udt, _("File corrupted"),
713             _("Downloaded file \"%s\" was corrupted. Thus, it was deleted."),
714              psz_destfile );
715         msg_Err( p_udt, "BAD SIGNATURE for %s", psz_destfile );
716         free( p_hash );
717         goto end;
718     }
719
720     msg_Info( p_udt, "%s authenticated", psz_destfile );
721     free( p_hash );
722
723 end:
724     if( p_progress )
725         dialog_ProgressDestroy( p_progress );
726     if( p_stream )
727         stream_Delete( p_stream );
728     if( p_file )
729         fclose( p_file );
730     free( psz_destdir );
731     free( psz_destfile );
732     free( p_buffer );
733     free( psz_size );
734
735     p_udt->p_update->p_download = NULL;
736
737     vlc_restorecancel( canc );
738     return NULL;
739 }
740
741 update_release_t *update_GetRelease( update_t *p_update )
742 {
743     return &p_update->release;
744 }
745
746 #else
747 update_t *__update_New( vlc_object_t *p_this )
748 {
749     (void)p_this;
750     return NULL;
751 }
752
753 void update_Delete( update_t *p_update )
754 {
755     (void)p_update;
756 }
757
758 void update_Check( update_t *p_update, void (*pf_callback)( void*, bool ),
759                    void *p_data )
760 {
761     (void)p_update; (void)pf_callback; (void)p_data;
762 }
763
764 bool update_NeedUpgrade( update_t *p_update )
765 {
766     (void)p_update;
767     return false;
768 }
769
770 void update_Download( update_t *p_update, const char *psz_destdir )
771 {
772     (void)p_update; (void)psz_destdir;
773 }
774
775 update_release_t *update_GetRelease( update_t *p_update )
776 {
777     (void)p_update;
778     return NULL;
779 }
780 #endif