2009-04-22 Nicolas François <nicolas.francois@centraliens.net>
- * libmisc/utmp.c: Added splint annotations.
+ * libmisc/utmp.c, libmisc/age.c, libmisc/shell.c, lib/groupio.c,
+ lib/groupio.h, lib/sgroupio.c, lib/sgroupio.h, lib/shadowio.c,
+ lib/pwio.c, lib/commonio.c, lib/shadowio.h, lib/pwio.h,
+ lib/commonio.h, lib/prototypes.h: Added splint annotations.
2009-04-22 Nicolas François <nicolas.francois@centraliens.net>
*
* Otherwise, it returns NULL.
*/
-const void *commonio_locate (struct commonio_db *db, const char *name)
+/*@null@*/const void *commonio_locate (struct commonio_db *db, const char *name)
{
struct commonio_entry *p;
*
* It returns the next entry, or NULL if no other entries could be found.
*/
-const void *commonio_next (struct commonio_db *db)
+/*@null@*/const void *commonio_next (struct commonio_db *db)
{
void *eptr;
* Linked list entry.
*/
struct commonio_entry {
- char *line;
- void *eptr; /* struct passwd, struct spwd, ... */
- struct commonio_entry *prev, *next;
+ /*@null@*/char *line;
+ /*@null@*/void *eptr; /* struct passwd, struct spwd, ... */
+ /*@null@*/struct commonio_entry *prev, *next;
bool changed:1;
};
/*
* free() the object including any strings pointed by it.
*/
- void (*free) (void *);
+ void (*free) (/*@out@*/ /*@only@*/void *);
/*
* Return the name of the object (for example, pw_name
* is open or before it is closed.
* They return 0 on failure and 1 on success.
*/
- int (*open_hook) (void);
- int (*close_hook) (void);
+ /*@null@*/int (*open_hook) (void);
+ /*@null@*/int (*close_hook) (void);
};
/*
/*
* Currently open file stream.
*/
- FILE *fp;
+ /*@null@*/FILE *fp;
#ifdef WITH_SELINUX
security_context_t scontext;
/*
* Head, tail, current position in linked list.
*/
- struct commonio_entry *head, *tail, *cursor;
+ /*@null@*/struct commonio_entry *head, *tail, *cursor;
/*
* Various flags.
extern int commonio_lock (struct commonio_db *);
extern int commonio_lock_nowait (struct commonio_db *);
extern int commonio_open (struct commonio_db *, int);
-extern const void *commonio_locate (struct commonio_db *, const char *);
+extern /*@null@*/const void *commonio_locate (struct commonio_db *, const char *);
extern int commonio_update (struct commonio_db *, const void *);
extern int commonio_remove (struct commonio_db *, const char *);
extern int commonio_rewind (struct commonio_db *);
-extern const void *commonio_next (struct commonio_db *);
+extern /*@null@*/const void *commonio_next (struct commonio_db *);
extern int commonio_close (struct commonio_db *);
extern int commonio_unlock (struct commonio_db *);
extern void commonio_del_entry (struct commonio_db *,
return __gr_dup (gr);
}
-static void group_free (void *ent)
+static void group_free (/*@out@*/ /*@only@*/void *ent)
{
struct group *gr = ent;
return commonio_setname (&group_db, filename);
}
-const char *gr_dbname (void)
+/*@observer@*/const char *gr_dbname (void)
{
return group_db.filename;
}
return commonio_open (&group_db, mode);
}
-const struct group *gr_locate (const char *name)
+/*@null@*/const struct group *gr_locate (const char *name)
{
return commonio_locate (&group_db, name);
}
-const struct group *gr_locate_gid (gid_t gid)
+/*@null@*/const struct group *gr_locate_gid (gid_t gid)
{
const struct group *grp;
return commonio_rewind (&group_db);
}
-const struct group *gr_next (void)
+/*@null@*/const struct group *gr_next (void)
{
return commonio_next (&group_db);
}
group_db.changed = true;
}
-struct commonio_entry *__gr_get_head (void)
+/*@null@*/struct commonio_entry *__gr_get_head (void)
{
return group_db.head;
}
#include <grp.h>
extern int gr_close (void);
-extern const struct group *gr_locate (const char *name);
-extern const struct group *gr_locate_gid (gid_t gid);
+extern /*@null@*/const struct group *gr_locate (const char *name);
+extern /*@null@*/const struct group *gr_locate_gid (gid_t gid);
extern int gr_lock (void);
extern int gr_setdbname (const char *filename);
-extern const char *gr_dbname (void);
-extern const struct group *gr_next (void);
+extern /*@observer@*/const char *gr_dbname (void);
+extern /*@null@*/const struct group *gr_next (void);
extern int gr_open (int mode);
extern int gr_remove (const char *name);
extern int gr_rewind (void);
#endif
/* age.c */
-extern void agecheck (const struct spwd *);
+extern void agecheck (/*@null@*/const struct spwd *);
extern int expire (const struct passwd *, const struct spwd *);
extern int isexpired (const struct passwd *, const struct spwd *);
/* groupio.c */
extern void __gr_del_entry (const struct commonio_entry *ent);
extern struct commonio_db *__gr_get_db (void);
-extern struct commonio_entry *__gr_get_head (void);
+extern /*@null@*/struct commonio_entry *__gr_get_head (void);
extern void __gr_set_changed (void);
/* groupmem.c */
-extern struct group *__gr_dup (const struct group *grent);
-extern void gr_free (struct group *grent);
+extern /*@null@*/ /*@only@*/struct group *__gr_dup (const struct group *grent);
+extern void gr_free (/*@out@*/ /*@only@*/struct group *grent);
/* hushed.c */
extern bool hushed (const char *username);
/* pwio.c */
extern void __pw_del_entry (const struct commonio_entry *ent);
extern struct commonio_db *__pw_get_db (void);
-extern struct commonio_entry *__pw_get_head (void);
+extern /*@null@*/struct commonio_entry *__pw_get_head (void);
/* pwmem.c */
-extern struct passwd *__pw_dup (const struct passwd *pwent);
-extern void pw_free (struct passwd *pwent);
+extern /*@null@*/ /*@only@*/struct passwd *__pw_dup (const struct passwd *pwent);
+extern void pw_free (/*@out@*/ /*@only@*/struct passwd *pwent);
/* rlogin.c */
extern int do_rlogin (const char *remote_host, char *name, size_t namelen,
/* sgetspent.c */
#ifndef HAVE_SGETSPENT
-extern struct spwd *sgetspent (const char *string)
+extern struct spwd *sgetspent (const char *string);
#endif
/* sgroupio.c */
extern void __sgr_del_entry (const struct commonio_entry *ent);
-extern struct sgrp *__sgr_dup (const struct sgrp *sgent);
-extern void sgr_free (struct sgrp *sgent);
-extern struct commonio_entry *__sgr_get_head (void);
+extern /*@null@*/ /*@only@*/struct sgrp *__sgr_dup (const struct sgrp *sgent);
+extern void sgr_free (/*@out@*/ /*@only@*/struct sgrp *sgent);
+extern /*@null@*/struct commonio_entry *__sgr_get_head (void);
extern void __sgr_set_changed (void);
/* shadowio.c */
-extern struct commonio_entry *__spw_get_head (void);
+extern /*@null@*/struct commonio_entry *__spw_get_head (void);
extern void __spw_del_entry (const struct commonio_entry *ent);
/* shadowmem.c */
-extern struct spwd *__spw_dup (const struct spwd *spent);
-extern void spw_free (struct spwd *spent);
+extern /*@null@*/ /*@only@*/struct spwd *__spw_dup (const struct spwd *spent);
+extern void spw_free (/*@out@*/ /*@only@*/struct spwd *spent);
/* shell.c */
-extern int shell (const char *, const char *, char *const *);
+extern int shell (const char *file, /*@null@*/const char *arg, char *const envp[]);
/* system.c */
extern int safe_system (const char *command,
extern int set_filesize_limit (int blocks);
/* utmp.c */
-extern struct utmp *get_current_utmp (void);
+extern /*@null@*/struct utmp *get_current_utmp (void);
extern struct utmp *prepare_utmp (const char *name,
const char *line,
const char *host,
- struct utmp *ut);
+ /*@null@*/const struct utmp *ut);
extern int setutmp (struct utmp *ut);
#ifdef HAVE_UTMPX_H
extern struct utmpx *prepare_utmpx (const char *name,
const char *line,
const char *host,
- struct utmp *ut);
+ /*@null@*/const struct utmp *ut);
extern int setutmpx (struct utmpx *utx);
#endif
extern bool valid (const char *, const struct passwd *);
/* xmalloc.c */
-extern char *xmalloc (size_t);
-extern char *xstrdup (const char *);
+extern /*@maynotreturn@*/ /*@only@*/char *xmalloc (size_t);
+extern /*@maynotreturn@*/ /*@only@*/char *xstrdup (const char *);
/* xgetpwnam.c */
extern struct passwd *xgetpwnam (const char *);
return __pw_dup (pw);
}
-static void passwd_free (void *ent)
+static void passwd_free (/*@out@*/ /*@only@*/void *ent)
{
struct passwd *pw = ent;
return commonio_setname (&passwd_db, filename);
}
-const char *pw_dbname (void)
+/*@observer@*/const char *pw_dbname (void)
{
return passwd_db.filename;
}
return commonio_unlock (&passwd_db);
}
-struct commonio_entry *__pw_get_head (void)
+/*@null@*/struct commonio_entry *__pw_get_head (void)
{
return passwd_db.head;
}
#include <pwd.h>
extern int pw_close (void);
-extern const struct passwd *pw_locate (const char *name);
-extern const struct passwd *pw_locate_uid (uid_t uid);
+extern /*@null@*/const struct passwd *pw_locate (const char *name);
+extern /*@null@*/const struct passwd *pw_locate_uid (uid_t uid);
extern int pw_lock (void);
extern int pw_setdbname (const char *filename);
-extern const char *pw_dbname (void);
-extern const struct passwd *pw_next (void);
+extern /*@observer@*/const char *pw_dbname (void);
+extern /*@null@*/const struct passwd *pw_next (void);
extern int pw_open (int mode);
extern int pw_remove (const char *name);
extern int pw_rewind (void);
return __sgr_dup (sg);
}
-static void gshadow_free (void *ent)
+static void gshadow_free (/*@out@*/ /*@only@*/void *ent)
{
struct sgrp *sg = ent;
sgr_free (sg);
}
-void sgr_free (struct sgrp *sgent)
+void sgr_free (/*@out@*/ /*@only@*/struct sgrp *sgent)
{
free (sgent->sg_name);
memzero (sgent->sg_passwd, strlen (sgent->sg_passwd));
return commonio_setname (&gshadow_db, filename);
}
-const char *sgr_dbname (void)
+/*@observer@*/const char *sgr_dbname (void)
{
return gshadow_db.filename;
}
return commonio_rewind (&gshadow_db);
}
-const struct sgrp *sgr_next (void)
+/*@null@*/const struct sgrp *sgr_next (void)
{
return commonio_next (&gshadow_db);
}
gshadow_db.changed = true;
}
-struct commonio_entry *__sgr_get_head (void)
+/*@null@*/struct commonio_entry *__sgr_get_head (void)
{
return gshadow_db.head;
}
extern int sgr_close (void);
extern bool sgr_file_present (void);
-extern const struct sgrp *sgr_locate (const char *name);
+extern /*@null@*/const struct sgrp *sgr_locate (const char *name);
extern int sgr_lock (void);
extern int sgr_setdbname (const char *filename);
-extern const char *sgr_dbname (void);
-extern const struct sgrp *sgr_next (void);
+extern /*@observer@*/const char *sgr_dbname (void);
+extern /*@null@*/const struct sgrp *sgr_next (void);
extern int sgr_open (int mode);
extern int sgr_remove (const char *name);
extern int sgr_rewind (void);
return __spw_dup (sp);
}
-static void shadow_free (void *ent)
+static void shadow_free (/*@out*//*@only@*/void *ent)
{
struct spwd *sp = ent;
return commonio_setname (&shadow_db, filename);
}
-const char *spw_dbname (void)
+/*@observer@*/const char *spw_dbname (void)
{
return shadow_db.filename;
}
return commonio_open (&shadow_db, mode);
}
-const struct spwd *spw_locate (const char *name)
+/*@null@*/const struct spwd *spw_locate (const char *name)
{
return commonio_locate (&shadow_db, name);
}
return commonio_rewind (&shadow_db);
}
-const struct spwd *spw_next (void)
+/*@null@*/const struct spwd *spw_next (void)
{
return commonio_next (&shadow_db);
}
extern int spw_close (void);
extern bool spw_file_present (void);
-extern const struct spwd *spw_locate (const char *name);
+extern /*@null@*/const struct spwd *spw_locate (const char *name);
extern int spw_lock (void);
extern int spw_setdbname (const char *filename);
-extern const char *spw_dbname (void);
-extern const struct spwd *spw_next (void);
+extern /*@observer@*/const char *spw_dbname (void);
+extern /*@null@*/const struct spwd *spw_next (void);
extern int spw_open (int mode);
extern int spw_remove (const char *name);
extern int spw_rewind (void);
* to expire and warns the user of the pending password expiration.
*/
-void agecheck (const struct spwd *sp)
+void agecheck (/*@null@*/const struct spwd *sp)
{
long now = (long) time ((time_t *) 0) / SCALE;
long remain;
* the file. If all that fails, give up in disgust ...
*/
-int shell (const char *file, const char *arg, char *const envp[])
+int shell (const char *file, /*@null@*/const char *arg, char *const envp[])
{
char arg0[1024];
int err;
*
* Return NULL if no entries exist in utmp for the current process.
*/
-/*@null@*//*@only@*/struct utmp *get_current_utmp (void)
+/*@null@*/ /*@only@*/struct utmp *get_current_utmp (void)
{
struct utmp *ut;
struct utmp *ret = NULL;