diff options
Diffstat (limited to '')
-rw-r--r-- | linden/indra/llmessage/llhttpassetstorage.cpp | 42 |
1 files changed, 28 insertions, 14 deletions
diff --git a/linden/indra/llmessage/llhttpassetstorage.cpp b/linden/indra/llmessage/llhttpassetstorage.cpp index 924d903..c5b897b 100644 --- a/linden/indra/llmessage/llhttpassetstorage.cpp +++ b/linden/indra/llmessage/llhttpassetstorage.cpp | |||
@@ -3,6 +3,8 @@ | |||
3 | * @brief Subclass capable of loading asset data to/from an external | 3 | * @brief Subclass capable of loading asset data to/from an external |
4 | * source. Currently, a web server accessed via curl | 4 | * source. Currently, a web server accessed via curl |
5 | * | 5 | * |
6 | * $LicenseInfo:firstyear=2003&license=viewergpl$ | ||
7 | * | ||
6 | * Copyright (c) 2003-2007, Linden Research, Inc. | 8 | * Copyright (c) 2003-2007, Linden Research, Inc. |
7 | * | 9 | * |
8 | * Second Life Viewer Source Code | 10 | * Second Life Viewer Source Code |
@@ -25,6 +27,7 @@ | |||
25 | * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO | 27 | * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO |
26 | * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, | 28 | * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, |
27 | * COMPLETENESS OR PERFORMANCE. | 29 | * COMPLETENESS OR PERFORMANCE. |
30 | * $/LicenseInfo$ | ||
28 | */ | 31 | */ |
29 | 32 | ||
30 | #include "linden_common.h" | 33 | #include "linden_common.h" |
@@ -336,15 +339,17 @@ size_t LLHTTPAssetRequest::readCompressedData(void* data, size_t size) | |||
336 | 339 | ||
337 | while (mZStream.avail_out > 0) | 340 | while (mZStream.avail_out > 0) |
338 | { | 341 | { |
339 | if (mZStream.avail_in == 0 && !mZInputExhausted) | 342 | if (mZStream.avail_in == 0 && !mZInputExhausted) |
340 | { | 343 | { |
341 | S32 to_read = llmin(COMPRESSED_INPUT_BUFFER_SIZE, | 344 | S32 to_read = llmin(COMPRESSED_INPUT_BUFFER_SIZE, |
342 | (S32)(mVFile->getSize() - mVFile->tell())); | 345 | (S32)(mVFile->getSize() - mVFile->tell())); |
343 | 346 | ||
344 | mVFile->read((U8*)mZInputBuffer, to_read); /*Flawfinder: ignore*/ | 347 | if ( to_read > 0 ) |
345 | 348 | { | |
346 | mZStream.next_in = (Bytef*)mZInputBuffer; | 349 | mVFile->read((U8*)mZInputBuffer, to_read); /*Flawfinder: ignore*/ |
347 | mZStream.avail_in = mVFile->getLastBytesRead(); | 350 | mZStream.next_in = (Bytef*)mZInputBuffer; |
351 | mZStream.avail_in = mVFile->getLastBytesRead(); | ||
352 | } | ||
348 | 353 | ||
349 | mZInputExhausted = mZStream.avail_in == 0; | 354 | mZInputExhausted = mZStream.avail_in == 0; |
350 | } | 355 | } |
@@ -352,8 +357,13 @@ size_t LLHTTPAssetRequest::readCompressedData(void* data, size_t size) | |||
352 | int r = deflate(&mZStream, | 357 | int r = deflate(&mZStream, |
353 | mZInputExhausted ? Z_FINISH : Z_NO_FLUSH); | 358 | mZInputExhausted ? Z_FINISH : Z_NO_FLUSH); |
354 | 359 | ||
355 | if (r == Z_STREAM_END) | 360 | if (r == Z_STREAM_END || r < 0 || mZInputExhausted) |
356 | { | 361 | { |
362 | if (r < 0) | ||
363 | { | ||
364 | llwarns << "LLHTTPAssetRequest::readCompressedData: deflate returned error code " | ||
365 | << (S32) r << llendl; | ||
366 | } | ||
357 | break; | 367 | break; |
358 | } | 368 | } |
359 | } | 369 | } |
@@ -365,15 +375,20 @@ size_t LLHTTPAssetRequest::readCompressedData(void* data, size_t size) | |||
365 | size_t LLHTTPAssetRequest::curlCompressedUploadCallback( | 375 | size_t LLHTTPAssetRequest::curlCompressedUploadCallback( |
366 | void *data, size_t size, size_t nmemb, void *user_data) | 376 | void *data, size_t size, size_t nmemb, void *user_data) |
367 | { | 377 | { |
368 | if (!gAssetStorage) | 378 | size_t num_read = 0; |
379 | |||
380 | if (gAssetStorage) | ||
369 | { | 381 | { |
370 | return 0; | 382 | CURL *curl_handle = (CURL *)user_data; |
383 | LLHTTPAssetRequest *req = NULL; | ||
384 | curl_easy_getinfo(curl_handle, CURLINFO_PRIVATE, &req); | ||
385 | if (req) | ||
386 | { | ||
387 | num_read = req->readCompressedData(data, size * nmemb); | ||
388 | } | ||
371 | } | 389 | } |
372 | CURL *curl_handle = (CURL *)user_data; | ||
373 | LLHTTPAssetRequest *req = NULL; | ||
374 | curl_easy_getinfo(curl_handle, CURLINFO_PRIVATE, &req); | ||
375 | 390 | ||
376 | return req->readCompressedData(data, size * nmemb); | 391 | return num_read; |
377 | } | 392 | } |
378 | 393 | ||
379 | ///////////////////////////////////////////////////////////////////////////////// | 394 | ///////////////////////////////////////////////////////////////////////////////// |
@@ -531,9 +546,8 @@ void LLHTTPAssetStorage::storeAssetData( | |||
531 | { | 546 | { |
532 | callback(LLUUID::null, user_data, LL_ERR_CANNOT_OPEN_FILE, LL_EXSTAT_BLOCKED_FILE); | 547 | callback(LLUUID::null, user_data, LL_ERR_CANNOT_OPEN_FILE, LL_EXSTAT_BLOCKED_FILE); |
533 | } | 548 | } |
549 | delete legacy; | ||
534 | } | 550 | } |
535 | // Coverity CID-269 says there's a leak of 'legacy' here, but | ||
536 | // legacyStoreDataCallback() will delete it somewhere down the line. | ||
537 | } | 551 | } |
538 | 552 | ||
539 | // virtual | 553 | // virtual |