diff options
author | Nicolas François <nicolas.francois@centraliens.net> | 2013-08-13 19:13:45 +0200 |
---|---|---|
committer | Nicolas François <nicolas.francois@centraliens.net> | 2013-08-13 19:13:45 +0200 |
commit | 64fe2f7db6c636d7ce4f1f0b9bca47dcc9136d5f (patch) | |
tree | bc15ee165ac17fd174ec75579fd957e5ad14208e | |
parent | 3bdf723bab6a4bf6c29d78a95b06670fb3bff2ce (diff) |
Add splint annotations.
* lib/groupmem.c: Add splint annotations. The added memset makes
splint think data was allocated.
* lib/pwmem.c: Likewise.
* lib/sgroupio.c: Likewise.
* lib/shadowmem.c: Likewise.
-rw-r--r-- | ChangeLog | 8 | ||||
-rw-r--r-- | lib/groupmem.c | 8 | ||||
-rw-r--r-- | lib/pwmem.c | 12 | ||||
-rw-r--r-- | lib/sgroupio.c | 10 | ||||
-rw-r--r-- | lib/shadowmem.c | 6 |
5 files changed, 40 insertions, 4 deletions
@@ -1,5 +1,13 @@ 2013-08-13 Nicolas François <nicolas.francois@centraliens.net> + * lib/groupmem.c: Add splint annotations. The added memset makes + splint think data was allocated. + * lib/pwmem.c: Likewise. + * lib/sgroupio.c: Likewise. + * lib/shadowmem.c: Likewise. + +2013-08-13 Nicolas François <nicolas.francois@centraliens.net> + * man/login.defs.d/SUB_GID_COUNT.xml: Document that the behavior of useradd and newusers depends on the existence of /etc/subgid. * man/login.defs.d/SUB_UID_COUNT.xml: Likewise for /etc/subuid. diff --git a/lib/groupmem.c b/lib/groupmem.c index f06ed3b2..e69c3107 100644 --- a/lib/groupmem.c +++ b/lib/groupmem.c @@ -3,7 +3,7 @@ * Copyright (c) 1996 - 2000, Marek Michałkiewicz * Copyright (c) 2001 , Michał Moskal * Copyright (c) 2005 , Tomasz Kłoczko - * Copyright (c) 2007 - 2010, Nicolas François + * Copyright (c) 2007 - 2013, Nicolas François * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -51,12 +51,16 @@ /* The libc might define other fields. They won't be copied. */ memset (gr, 0, sizeof *gr); gr->gr_gid = grent->gr_gid; + /*@-mustfreeonly@*/ gr->gr_name = strdup (grent->gr_name); + /*@=mustfreeonly@*/ if (NULL == gr->gr_name) { free(gr); return NULL; } + /*@-mustfreeonly@*/ gr->gr_passwd = strdup (grent->gr_passwd); + /*@=mustfreeonly@*/ if (NULL == gr->gr_passwd) { free(gr->gr_name); free(gr); @@ -65,7 +69,9 @@ for (i = 0; grent->gr_mem[i]; i++); + /*@-mustfreeonly@*/ gr->gr_mem = (char **) malloc ((i + 1) * sizeof (char *)); + /*@=mustfreeonly@*/ if (NULL == gr->gr_mem) { free(gr->gr_passwd); free(gr->gr_name); diff --git a/lib/pwmem.c b/lib/pwmem.c index 9786d5b6..7013e8a3 100644 --- a/lib/pwmem.c +++ b/lib/pwmem.c @@ -3,7 +3,7 @@ * Copyright (c) 1996 - 2000, Marek Michałkiewicz * Copyright (c) 2001 , Michał Moskal * Copyright (c) 2003 - 2005, Tomasz Kłoczko - * Copyright (c) 2007 - 2009, Nicolas François + * Copyright (c) 2007 - 2013, Nicolas François * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -52,25 +52,33 @@ memset (pw, 0, sizeof *pw); pw->pw_uid = pwent->pw_uid; pw->pw_gid = pwent->pw_gid; + /*@-mustfreeonly@*/ pw->pw_name = strdup (pwent->pw_name); + /*@=mustfreeonly@*/ if (NULL == pw->pw_name) { free(pw); return NULL; } + /*@-mustfreeonly@*/ pw->pw_passwd = strdup (pwent->pw_passwd); + /*@=mustfreeonly@*/ if (NULL == pw->pw_passwd) { free(pw->pw_name); free(pw); return NULL; } + /*@-mustfreeonly@*/ pw->pw_gecos = strdup (pwent->pw_gecos); + /*@=mustfreeonly@*/ if (NULL == pw->pw_gecos) { free(pw->pw_passwd); free(pw->pw_name); free(pw); return NULL; } + /*@-mustfreeonly@*/ pw->pw_dir = strdup (pwent->pw_dir); + /*@=mustfreeonly@*/ if (NULL == pw->pw_dir) { free(pw->pw_gecos); free(pw->pw_passwd); @@ -78,7 +86,9 @@ free(pw); return NULL; } + /*@-mustfreeonly@*/ pw->pw_shell = strdup (pwent->pw_shell); + /*@=mustfreeonly@*/ if (NULL == pw->pw_shell) { free(pw->pw_dir); free(pw->pw_gecos); diff --git a/lib/sgroupio.c b/lib/sgroupio.c index 7b51f015..faed0adf 100644 --- a/lib/sgroupio.c +++ b/lib/sgroupio.c @@ -3,7 +3,7 @@ * Copyright (c) 1996 - 2000, Marek Michałkiewicz * Copyright (c) 2001 , Michał Moskal * Copyright (c) 2005 , Tomasz Kłoczko - * Copyright (c) 2007 - 2008, Nicolas François + * Copyright (c) 2007 - 2013, Nicolas François * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -54,12 +54,16 @@ /* Do the same as the other _dup function, even if we know the * structure. */ memset (sg, 0, sizeof *sg); + /*@-mustfreeonly@*/ sg->sg_name = strdup (sgent->sg_name); + /*@=mustfreeonly@*/ if (NULL == sg->sg_name) { free (sg); return NULL; } + /*@-mustfreeonly@*/ sg->sg_passwd = strdup (sgent->sg_passwd); + /*@=mustfreeonly@*/ if (NULL == sg->sg_passwd) { free (sg->sg_name); free (sg); @@ -67,7 +71,9 @@ } for (i = 0; NULL != sgent->sg_adm[i]; i++); + /*@-mustfreeonly@*/ sg->sg_adm = (char **) malloc ((i + 1) * sizeof (char *)); + /*@=mustfreeonly@*/ if (NULL == sg->sg_adm) { free (sg->sg_passwd); free (sg->sg_name); @@ -90,7 +96,9 @@ sg->sg_adm[i] = NULL; for (i = 0; NULL != sgent->sg_mem[i]; i++); + /*@-mustfreeonly@*/ sg->sg_mem = (char **) malloc ((i + 1) * sizeof (char *)); + /*@=mustfreeonly@*/ if (NULL == sg->sg_mem) { for (i = 0; NULL != sg->sg_adm[i]; i++) { free (sg->sg_adm[i]); diff --git a/lib/shadowmem.c b/lib/shadowmem.c index 41dbc40e..8989598f 100644 --- a/lib/shadowmem.c +++ b/lib/shadowmem.c @@ -3,7 +3,7 @@ * Copyright (c) 1996 - 2000, Marek Michałkiewicz * Copyright (c) 2001 , Michał Moskal * Copyright (c) 2005 , Tomasz Kłoczko - * Copyright (c) 2007 - 2009, Nicolas François + * Copyright (c) 2007 - 2013, Nicolas François * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -58,12 +58,16 @@ sp->sp_inact = spent->sp_inact; sp->sp_expire = spent->sp_expire; sp->sp_flag = spent->sp_flag; + /*@-mustfreeonly@*/ sp->sp_namp = strdup (spent->sp_namp); + /*@=mustfreeonly@*/ if (NULL == sp->sp_namp) { free(sp); return NULL; } + /*@-mustfreeonly@*/ sp->sp_pwdp = strdup (spent->sp_pwdp); + /*@=mustfreeonly@*/ if (NULL == sp->sp_pwdp) { free(sp->sp_namp); free(sp); |