* libmisc/xgetXXbyYY.c, libmisc/myname.c, libmisc/getgr_nam_gid.c,
libmisc/salt.c, libmisc/list.c, libmisc/cleanup.c, src/login.c, lib/getdef.h, lib/groupio.c, lib/getlong.c, lib/gshadow_.h, lib/sgroupio.c, lib/shadowio.c, lib/pwio.c, lib/commonio.h, lib/fputsx.c, lib/prototypes.h: Added splint annotations. * lib/groupio.c: Avoid implicit conversion of pointers to booleans. * lib/groupio.c: Free allocated buffers in case of failure.
This commit is contained in:
@@ -38,7 +38,7 @@ extern long getdef_long (const char *, long);
|
||||
extern int getdef_num (const char *, int);
|
||||
extern unsigned long getdef_ulong (const char *, unsigned long);
|
||||
extern unsigned int getdef_unum (const char *, unsigned int);
|
||||
extern char *getdef_str (const char *);
|
||||
extern /*@observer@*/ /*@null@*/const char *getdef_str (const char *);
|
||||
extern int putdef_str (const char *, const char *);
|
||||
|
||||
/* default UMASK value if not specified in /etc/login.defs */
|
||||
|
||||
@@ -42,7 +42,7 @@
|
||||
*
|
||||
* Returns 0 on failure, 1 on success.
|
||||
*/
|
||||
int getlong (const char *numstr, long int *result)
|
||||
int getlong (const char *numstr, /*@out@*/long int *result)
|
||||
{
|
||||
long val;
|
||||
char *endptr;
|
||||
|
||||
@@ -43,12 +43,13 @@
|
||||
#include "getdef.h"
|
||||
#include "groupio.h"
|
||||
|
||||
static struct commonio_entry *merge_group_entries (struct commonio_entry *gr1,
|
||||
struct commonio_entry *gr2);
|
||||
static /*@null@*/struct commonio_entry *merge_group_entries (
|
||||
/*@null@*/struct commonio_entry *gr1,
|
||||
/*@null@*/struct commonio_entry *gr2);
|
||||
static int split_groups (unsigned int max_members);
|
||||
static int group_open_hook (void);
|
||||
|
||||
static void *group_dup (const void *ent)
|
||||
static /*@null@*/ /*@only@*/void *group_dup (const void *ent)
|
||||
{
|
||||
const struct group *gr = ent;
|
||||
|
||||
@@ -245,8 +246,8 @@ static int group_open_hook (void)
|
||||
return 1;
|
||||
}
|
||||
|
||||
for (gr1 = group_db.head; gr1; gr1 = gr1->next) {
|
||||
for (gr2 = gr1->next; gr2; gr2 = gr2->next) {
|
||||
for (gr1 = group_db.head; NULL != gr1; gr1 = gr1->next) {
|
||||
for (gr2 = gr1->next; NULL != gr2; gr2 = gr2->next) {
|
||||
struct group *g1 = (struct group *)gr1->eptr;
|
||||
struct group *g2 = (struct group *)gr2->eptr;
|
||||
if (NULL != g1 &&
|
||||
@@ -284,8 +285,9 @@ static int group_open_hook (void)
|
||||
* the modified first entry on success, or NULL on failure (with errno
|
||||
* set).
|
||||
*/
|
||||
static struct commonio_entry *merge_group_entries (struct commonio_entry *gr1,
|
||||
struct commonio_entry *gr2)
|
||||
static /*@null@*/struct commonio_entry *merge_group_entries (
|
||||
/*@null@*/struct commonio_entry *gr1,
|
||||
/*@null@*/struct commonio_entry *gr2)
|
||||
{
|
||||
struct group *gptr1;
|
||||
struct group *gptr2;
|
||||
@@ -332,6 +334,7 @@ static struct commonio_entry *merge_group_entries (struct commonio_entry *gr1,
|
||||
}
|
||||
new_members = (char **)malloc ( (members+1) * sizeof(char*) );
|
||||
if (NULL == new_members) {
|
||||
free (new_line);
|
||||
errno = ENOMEM;
|
||||
return NULL;
|
||||
}
|
||||
@@ -370,7 +373,7 @@ static int split_groups (unsigned int max_members)
|
||||
{
|
||||
struct commonio_entry *gr;
|
||||
|
||||
for (gr = group_db.head; gr; gr = gr->next) {
|
||||
for (gr = group_db.head; NULL != gr; gr = gr->next) {
|
||||
struct group *gptr = (struct group *)gr->eptr;
|
||||
struct commonio_entry *new;
|
||||
struct group *new_gptr;
|
||||
@@ -392,6 +395,7 @@ static int split_groups (unsigned int max_members)
|
||||
}
|
||||
new->eptr = group_dup(gr->eptr);
|
||||
if (NULL == new->eptr) {
|
||||
free (new);
|
||||
errno = ENOMEM;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -54,18 +54,18 @@ struct sgrp {
|
||||
#include <stdio.h> /* for FILE */
|
||||
|
||||
#if __STDC__
|
||||
struct sgrp *getsgent (void);
|
||||
struct sgrp *getsgnam (const char *);
|
||||
struct sgrp *sgetsgent (const char *);
|
||||
struct sgrp *fgetsgent (FILE *);
|
||||
/*@observer@*//*@null@*/struct sgrp *getsgent (void);
|
||||
/*@observer@*//*@null@*/struct sgrp *getsgnam (const char *);
|
||||
/*@observer@*//*@null@*/struct sgrp *sgetsgent (const char *);
|
||||
/*@observer@*//*@null@*/struct sgrp *fgetsgent (/*@null@*/FILE *);
|
||||
void setsgent (void);
|
||||
void endsgent (void);
|
||||
int putsgent (const struct sgrp *, FILE *);
|
||||
#else
|
||||
struct sgrp *getsgent ();
|
||||
struct sgrp *getsgnam ();
|
||||
struct sgrp *sgetsgent ();
|
||||
struct sgrp *fgetsgent ();
|
||||
/*@observer@*//*@null@*/struct sgrp *getsgent ();
|
||||
/*@observer@*//*@null@*/struct sgrp *getsgnam ();
|
||||
/*@observer@*//*@null@*/struct sgrp *sgetsgent ();
|
||||
/*@observer@*//*@null@*/struct sgrp *fgetsgent ();
|
||||
void setsgent ();
|
||||
void endsgent ();
|
||||
int putsgent ();
|
||||
|
||||
@@ -80,8 +80,8 @@ extern int chown_tree (const char *, uid_t, uid_t, gid_t, gid_t);
|
||||
extern void chown_tty (const struct passwd *);
|
||||
|
||||
/* cleanup.c */
|
||||
typedef void (*cleanup_function) (void *arg);
|
||||
void add_cleanup (cleanup_function pcf, void *arg);
|
||||
typedef void (*cleanup_function) (/*@null@*/void *arg);
|
||||
void add_cleanup (cleanup_function pcf, /*@null@*/void *arg);
|
||||
void del_cleanup (cleanup_function pcf);
|
||||
void do_cleanups (void);
|
||||
|
||||
@@ -104,11 +104,11 @@ void cleanup_report_del_group_gshadow (void *group_name);
|
||||
void cleanup_report_mod_passwd (void *cleanup_info);
|
||||
void cleanup_report_mod_group (void *cleanup_info);
|
||||
void cleanup_report_mod_gshadow (void *cleanup_info);
|
||||
void cleanup_unlock_group (void *unused);
|
||||
void cleanup_unlock_group (/*@null@*/void *unused);
|
||||
#ifdef SHADOWGRP
|
||||
void cleanup_unlock_gshadow (void *unused);
|
||||
void cleanup_unlock_gshadow (/*@null@*/void *unused);
|
||||
#endif
|
||||
void cleanup_unlock_passwd (void *unused);
|
||||
void cleanup_unlock_passwd (/*@null@*/void *unused);
|
||||
|
||||
/* console.c */
|
||||
extern bool console (const char *);
|
||||
@@ -148,10 +148,10 @@ extern int find_new_uid (bool sys_user, uid_t *uid, uid_t const *preferred_uid);
|
||||
extern int get_gid (const char *gidstr, gid_t *gid);
|
||||
|
||||
/* getgr_nam_gid.c */
|
||||
extern struct group *getgr_nam_gid (const char *grname);
|
||||
extern /*@null@*/struct group *getgr_nam_gid (const char *grname);
|
||||
|
||||
/* getlong.c */
|
||||
extern int getlong (const char *numstr, long int *result);
|
||||
extern int getlong (const char *numstr, /*@out@*/long int *result);
|
||||
|
||||
/* getrange */
|
||||
extern int getrange (char *range,
|
||||
@@ -162,7 +162,7 @@ extern int getrange (char *range,
|
||||
extern int get_uid (const char *uidstr, uid_t *uid);
|
||||
|
||||
/* fputsx.c */
|
||||
extern char *fgetsx (char *, int, FILE *);
|
||||
extern /*@null@*/char *fgetsx (/*@returned@*/ /*@out@*/char *, int, FILE *);
|
||||
extern int fputsx (const char *, FILE *);
|
||||
|
||||
/* groupio.c */
|
||||
@@ -199,11 +199,11 @@ extern void setup_limits (const struct passwd *);
|
||||
#endif
|
||||
|
||||
/* list.c */
|
||||
extern char **add_list (char **, const char *);
|
||||
extern char **del_list (char **, const char *);
|
||||
extern char **dup_list (char *const *);
|
||||
extern /*@only@*/ /*@out@*/char **add_list (/*@returned@*/ /*@only@*/char **, const char *);
|
||||
extern /*@only@*/ /*@out@*/char **del_list (/*@returned@*/ /*@only@*/char **, const char *);
|
||||
extern /*@only@*/ /*@out@*/char **dup_list (char *const *);
|
||||
extern bool is_on_list (char *const *list, const char *member);
|
||||
extern char **comma_to_list (const char *);
|
||||
extern /*@only@*/char **comma_to_list (const char *);
|
||||
|
||||
/* log.c */
|
||||
extern void dolastlog (struct lastlog *ll,
|
||||
@@ -224,7 +224,7 @@ extern void mailcheck (void);
|
||||
extern void motd (void);
|
||||
|
||||
/* myname.c */
|
||||
extern struct passwd *get_my_pwent (void);
|
||||
extern /*@null@*/struct passwd *get_my_pwent (void);
|
||||
|
||||
/* obscure.c */
|
||||
#ifndef USE_PAM
|
||||
@@ -266,7 +266,7 @@ extern int do_rlogin (const char *remote_host, char *name, size_t namelen,
|
||||
char *term, size_t termlen);
|
||||
|
||||
/* salt.c */
|
||||
extern char *crypt_make_salt (const char *meth, void *arg);
|
||||
extern /*@observer@*/const char *crypt_make_salt (/*@null@*/const char *meth, /*@null@*/void *arg);
|
||||
|
||||
/* setugid.c */
|
||||
extern int setup_groups (const struct passwd *info);
|
||||
@@ -367,15 +367,15 @@ extern /*@maynotreturn@*/ /*@only@*/char *xmalloc (size_t);
|
||||
extern /*@maynotreturn@*/ /*@only@*/char *xstrdup (const char *);
|
||||
|
||||
/* xgetpwnam.c */
|
||||
extern struct passwd *xgetpwnam (const char *);
|
||||
extern /*@null@*/ /*@only@*/struct passwd *xgetpwnam (const char *);
|
||||
/* xgetpwuid.c */
|
||||
extern struct passwd *xgetpwuid (uid_t);
|
||||
extern /*@null@*/ /*@only@*/struct passwd *xgetpwuid (uid_t);
|
||||
/* xgetgrnam.c */
|
||||
extern struct group *xgetgrnam (const char *);
|
||||
extern /*@null@*/ /*@only@*/struct group *xgetgrnam (const char *);
|
||||
/* xgetgrgid.c */
|
||||
extern struct group *xgetgrgid (gid_t);
|
||||
extern /*@null@*/ /*@only@*/struct group *xgetgrgid (gid_t);
|
||||
/* xgetspnam.c */
|
||||
extern struct spwd *xgetspnam(const char *);
|
||||
extern /*@null@*/ /*@only@*/struct spwd *xgetspnam(const char *);
|
||||
|
||||
/* yesno.c */
|
||||
extern bool yes_or_no (bool read_only);
|
||||
|
||||
@@ -42,7 +42,7 @@
|
||||
#include "commonio.h"
|
||||
#include "pwio.h"
|
||||
|
||||
static void *passwd_dup (const void *ent)
|
||||
static /*@null@*/ /*@only@*/void *passwd_dup (const void *ent)
|
||||
{
|
||||
const struct passwd *pw = ent;
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@
|
||||
#include "commonio.h"
|
||||
#include "sgroupio.h"
|
||||
|
||||
struct sgrp *__sgr_dup (const struct sgrp *sgent)
|
||||
/*@null@*/ /*@only@*/struct sgrp *__sgr_dup (const struct sgrp *sgent)
|
||||
{
|
||||
struct sgrp *sg;
|
||||
int i;
|
||||
@@ -90,7 +90,7 @@ struct sgrp *__sgr_dup (const struct sgrp *sgent)
|
||||
return sg;
|
||||
}
|
||||
|
||||
static void *gshadow_dup (const void *ent)
|
||||
static /*@null@*/ /*@only@*/void *gshadow_dup (const void *ent)
|
||||
{
|
||||
const struct sgrp *sg = ent;
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@
|
||||
#include "commonio.h"
|
||||
#include "shadowio.h"
|
||||
|
||||
static void *shadow_dup (const void *ent)
|
||||
static /*@null@*/ /*@only@*/void *shadow_dup (const void *ent)
|
||||
{
|
||||
const struct spwd *sp = ent;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user