- if( cur >= end )
- {
- hb_log("Error: Found the end of the buffer before the end of the HTTP header information! \n");
- goto error;
- }
-
- /*
- * Find the <cli> tag
- * Scan though each character of the buffer until we find that the first 4 characters of "cur" are "<cli"
- */
- for(i=0 ; &cur[3] < end; i++, cur++ )
- {
- if( cur[0] == 'c' && cur[1] == 'l' && cur[2] == 'i' && cur[3] == '>' )
- {
- cur += 1;
- break;
- }
-
- /* If the CLI tag has not been found in the first 768 characters, or the end is reached, something bad happened.*/
- if (( i > 768) || ( cur >= end ))
- {
- hb_log("Error: Did not find the <cli> tag in the expected maximum amount of characters into the file. \n");
- goto error;
- }
- }
-
- if( cur >= end )
- {
- goto error;
- }
-
- /*
- * Ok, The above code didn't position cur, it only found <cli so we need to shift cur along 3 places.
- * After which, the next 10 characters are the build number
- */
- cur += 3;
-
- if( cur >= end )
- {
- hb_log("Error: Unexpected end of buffer! Could not find the build information. \n");
- goto error;
- }
-
- /* Stable HB_BUILD */
- stable = strtol( cur, &cur, 10 );
-
- if( cur >= end )
- {
- hb_log("Error: Unexpected end of buffer! \n");
- goto error;
- }
-
- /*
- * The Version number is 2 places after the build, so shift cur, 2 places.
- * Get all the characters in cur until the point where " is found.
- */
- cur += 2;
-
- if( cur >= end )
- {
- hb_log("Error: Unexpected end of buffer! Could not get version number. \n");
- goto error;
- }
- memset( stable_str, 0, sizeof( stable_str ) );
- for( i = 0; i < sizeof( stable_str ) - 1 && cur < end && *cur != '"'; i++, cur++ )
- {
- stable_str[i] = *cur;
-
- /* If the CLI tag has not been found in the first 768 characters, or the end is reached, something bad happened.*/
- if (( i > 7) || ( cur >= end ))
- {
- hb_log("Error: Version number too long, or end of buffer reached. \n");
- goto error;
- }
- }
-
- if( cur >= end )
- {
- goto error;
- }
-
- /* HANDLE THE SECOND APPCAST FILE NOW */