Handle NULL names better
Subsystems (2)
PATCH 1/1 Handle NULL names better
Detect when an application passes in NULL names
and fail gracefully instead of crashing hard.
Signed-off-by Steve Dickson <[email protected]>
--- libnfsidmap.c | 5 ++++- nss.c | 3 +++ 2 files changed, 7 insertions(+), 1 deletion(-)
libnfsidmap.c +4 -1
@@ -100,8 +100,11 @@ static char * toupper_str(char *s)static int id_as_chars (char *name,uid_t *id) { -long int value =strtol (name,NULL ,10 ); +long int value; +if (name ==NULL ) +return 0 ; + value =strtol (name,NULL ,10 );if (value ==0 ) {/* zero value ids are valid */ if (strcmp (name,"0" ) !=0 )
nss.c +3 -0
@@ -135,6 +135,9 @@ static char *strip_domain(const char *name, const char *domain)char *l =NULL ;int len; +if (name ==NULL ) + goto out; + c =strrchr (name,'@' );if (c ==NULL && domain !=NULL ) goto out;
Signature · 1 line
2.1.0
PATCH 1/1 nfsidmap: make sure given arguments are valid
Detect when a given argument is invalid. Log
the error and exit gracefully
Signed-off-by Steve Dickson <[email protected]>
--- utils/nfsidmap/nfsidmap.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
utils/nfsidmap/nfsidmap.c +4 -1
@@ -323,7 +323,10 @@ int main(int argc, char **argv) } type =strtok (arg,":" ); value =strtok (NULL ,":" ); - +if (value ==NULL ) { +xlog_err ("Error: Null uid/gid value." ); +return 1 ; + }if (verbose) {xlog_warn ("key: 0x%lx type: %s value: %s timeout %ld" , key, type, value, timeout);
Signature · 1 line
2.1.0
Re: [PATCH] nfsidmap: make sure given arguments are valid
Quoted 4 lines · Steve Dickson
Detect when a given argument is invalid. Log
the error and exit gracefullySigned-off-by Steve Dickson <[email protected]>
Committed...
steved.
Quoted 21 lines
--- utils/nfsidmap/nfsidmap.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)utils/nfsidmap/nfsidmap.c +4
-1@@ -323,7 +323,10 @@ int main(int argc, char **argv) } type =strtok (arg,":" ); value =strtok (NULL ,":" ); - +if (value ==NULL ) { +xlog_err ("Error: Null uid/gid value." ); +return 1 ; + }if (verbose) {xlog_warn ("key: 0x%lx type: %s value: %s timeout %ld" , key, type, value, timeout);
Quoted 4 lines · Steve Dickson
Detect when an application passes in NULL names
and fail gracefully instead of crashing hard.Signed-off-by Steve Dickson <[email protected]>
Committed...
steved.
Quoted 37 lines
--- libnfsidmap.c | 5 ++++- nss.c | 3 +++ 2 files changed, 7 insertions(+), 1 deletion(-)libnfsidmap.c +4
-1@@ -100,8 +100,11 @@ static char * toupper_str(char *s)static int id_as_chars (char *name,uid_t *id) { -long int value =strtol (name,NULL ,10 ); +long int value; +if (name ==NULL ) +return 0 ; + value =strtol (name,NULL ,10 );if (value ==0 ) {/* zero value ids are valid */ if (strcmp (name,"0" ) !=0 )nss.c +3
-0@@ -135,6 +135,9 @@ static char *strip_domain(const char *name, const char *domain)char *l =NULL ;int len; +if (name ==NULL ) + goto out; + c =strrchr (name,'@' );if (c ==NULL && domain !=NULL ) goto out;