diff options
Diffstat (limited to 'tool/showwal.c')
-rw-r--r-- | tool/showwal.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/tool/showwal.c b/tool/showwal.c index bc7406dc1..84e4afa13 100644 --- a/tool/showwal.c +++ b/tool/showwal.c @@ -512,6 +512,18 @@ static void decode_btree_page( } } +/* +** Check the range validity for a page number. Print an error and +** exit if the page is out of range. +*/ +static void checkPageValidity(int iPage, int mxPage){ + if( iPage<1 || iPage>mxPage ){ + fprintf(stderr, "Invalid page number %d: valid range is 1..%d\n", + iPage, mxPage); + exit(1); + } +} + int main(int argc, char **argv){ struct stat sbuf; unsigned char zPgSz[4]; @@ -559,10 +571,12 @@ int main(int argc, char **argv){ continue; } iStart = strtol(argv[i], &zLeft, 0); + checkPageValidity(iStart, mxFrame); if( zLeft && strcmp(zLeft,"..end")==0 ){ iEnd = mxFrame; }else if( zLeft && zLeft[0]=='.' && zLeft[1]=='.' ){ iEnd = strtol(&zLeft[2], 0, 0); + checkPageValidity(iEnd, mxFrame); }else if( zLeft && zLeft[0]=='b' ){ i64 ofst; int nByte, hdrSize; |