From d1b713035c921f264093967353399db953a0644d Mon Sep 17 00:00:00 2001 From: t-m Date: Sat, 13 Jan 2024 20:28:38 +0100 Subject: [PATCH] adfMount: a more complete parameter check. --- src/adf_vol.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/adf_vol.c b/src/adf_vol.c index e26dde26..b7c72e9d 100644 --- a/src/adf_vol.c +++ b/src/adf_vol.c @@ -176,8 +176,22 @@ PREFIX struct AdfVolume * adfMount ( struct AdfDevice * const dev, struct bBootBlock boot; struct AdfVolume * vol; - if (dev==NULL || nPart >= dev->nVol) { - (*adfEnv.eFct)("adfMount : invalid parameter(s)"); + if ( dev == NULL ) { + adfEnv.eFct ( "adfMount : invalid device (NULL)" ); + return NULL; + } + + if ( nPart < 0 || + nPart >= dev->nVol ) + { + adfEnv.eFct ( "adfMount : invalid partition %d", nPart ); + return NULL; + } + + if ( mode != ADF_ACCESS_MODE_READONLY && + mode != ADF_ACCESS_MODE_READWRITE ) + { + adfEnv.eFct ( "adfMount : invalid mode %d", mode ); return NULL; }