]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
changed error code when pos<=size condition is not respected
authorYann Collet <cyan@fb.com>
Wed, 27 Sep 2017 17:35:56 +0000 (10:35 -0700)
committerYann Collet <cyan@fb.com>
Wed, 27 Sep 2017 17:35:56 +0000 (10:35 -0700)
Now pointing towards src_size or dst_size,
instead of error_GENERIC.

lib/common/error_private.c
lib/common/zstd_errors.h
lib/decompress/zstd_decompress.c

index 8045e445e051faae7af595ade9ba5b192063d7ad..11f7cdab1c6007f479446f90c18256681e7bf0e4 100644 (file)
@@ -30,14 +30,15 @@ const char* ERR_getErrorString(ERR_enum code)
     case PREFIX(init_missing): return "Context should be init first";
     case PREFIX(memory_allocation): return "Allocation error : not enough memory";
     case PREFIX(stage_wrong): return "Operation not authorized at current processing stage";
-    case PREFIX(dstSize_tooSmall): return "Destination buffer is too small";
-    case PREFIX(srcSize_wrong): return "Src size is incorrect";
     case PREFIX(tableLog_tooLarge): return "tableLog requires too much memory : unsupported";
     case PREFIX(maxSymbolValue_tooLarge): return "Unsupported max Symbol Value : too large";
     case PREFIX(maxSymbolValue_tooSmall): return "Specified maxSymbolValue is too small";
     case PREFIX(dictionary_corrupted): return "Dictionary is corrupted";
     case PREFIX(dictionary_wrong): return "Dictionary mismatch";
     case PREFIX(dictionaryCreation_failed): return "Cannot create Dictionary from provided samples";
+    case PREFIX(dstSize_tooSmall): return "Destination buffer is too small";
+    case PREFIX(srcSize_wrong): return "Src size is incorrect";
+        /* following error codes are not stable and may be removed or changed in a future version */
     case PREFIX(frameIndex_tooLarge): return "Frame index is too large";
     case PREFIX(seekableIO): return "An I/O error occurred when reading/seeking";
     case PREFIX(maxCode):
index bde4304c93ca33edd89350ae1117d13a0ee407c1..4bcb7769fe77dc6e7a363141502a8a3312676c3b 100644 (file)
@@ -63,9 +63,10 @@ typedef enum {
   ZSTD_error_memory_allocation = 64,
   ZSTD_error_dstSize_tooSmall = 70,
   ZSTD_error_srcSize_wrong    = 72,
+  /* following error codes are not stable and may be removed or changed in a future version */
   ZSTD_error_frameIndex_tooLarge = 100,
   ZSTD_error_seekableIO          = 102,
-  ZSTD_error_maxCode = 120  /* never EVER use this value directly, it may change in future versions! Use ZSTD_isError() instead */
+  ZSTD_error_maxCode = 120  /* never EVER use this value directly, it can change in future versions! Use ZSTD_isError() instead */
 } ZSTD_ErrorCode;
 
 /*! ZSTD_getErrorCode() :
index 0380f6a109b4ba46ee02456b51d3f6d81f5ddba4..332bf860d2bd646b5095db41cda743f13691a6ee 100644 (file)
@@ -2407,12 +2407,12 @@ size_t ZSTD_decompressStream(ZSTD_DStream* zds, ZSTD_outBuffer* output, ZSTD_inB
     if (input->pos > input->size) {  /* forbidden */
         DEBUGLOG(5, "in: pos: %u   vs size: %u",
                     (U32)input->pos, (U32)input->size);
-        return ERROR(GENERIC);
+        return ERROR(srcSize_wrong);
     }
     if (output->pos > output->size) {  /* forbidden */
         DEBUGLOG(5, "out: pos: %u   vs size: %u",
                     (U32)output->pos, (U32)output->size);
-        return ERROR(GENERIC);
+        return ERROR(dstSize_tooSmall);
     }
     DEBUGLOG(5, "input size : %u", (U32)(input->size - input->pos));