[Pkg-shadow-commits] r2763 - in upstream/trunk: . lib libmisc src

Nicolas FRANÇOIS nekral-guest at alioth.debian.org
Thu Apr 23 09:57:04 UTC 2009


Author: nekral-guest
Date: 2009-04-23 09:57:03 +0000 (Thu, 23 Apr 2009)
New Revision: 2763

Modified:
   upstream/trunk/ChangeLog
   upstream/trunk/lib/getdef.h
   upstream/trunk/lib/getlong.c
   upstream/trunk/lib/groupio.c
   upstream/trunk/lib/gshadow_.h
   upstream/trunk/lib/prototypes.h
   upstream/trunk/lib/pwio.c
   upstream/trunk/lib/sgroupio.c
   upstream/trunk/lib/shadowio.c
   upstream/trunk/libmisc/cleanup.c
   upstream/trunk/libmisc/getgr_nam_gid.c
   upstream/trunk/libmisc/list.c
   upstream/trunk/libmisc/myname.c
   upstream/trunk/libmisc/salt.c
   upstream/trunk/libmisc/xgetXXbyYY.c
   upstream/trunk/src/login.c
Log:
	* 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.


Modified: upstream/trunk/ChangeLog
===================================================================
--- upstream/trunk/ChangeLog	2009-04-22 21:33:09 UTC (rev 2762)
+++ upstream/trunk/ChangeLog	2009-04-23 09:57:03 UTC (rev 2763)
@@ -1,5 +1,16 @@
 2009-04-22  Nicolas François  <nicolas.francois at centraliens.net>
 
+	* 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.
+
+2009-04-22  Nicolas François  <nicolas.francois at centraliens.net>
+
 	* lib/defines.h: Added splint definitions to replace <locale.h>
 
 2009-04-22  Nicolas François  <nicolas.francois at centraliens.net>

Modified: upstream/trunk/lib/getdef.h
===================================================================
--- upstream/trunk/lib/getdef.h	2009-04-22 21:33:09 UTC (rev 2762)
+++ upstream/trunk/lib/getdef.h	2009-04-23 09:57:03 UTC (rev 2763)
@@ -38,7 +38,7 @@
 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 */

Modified: upstream/trunk/lib/getlong.c
===================================================================
--- upstream/trunk/lib/getlong.c	2009-04-22 21:33:09 UTC (rev 2762)
+++ upstream/trunk/lib/getlong.c	2009-04-23 09:57:03 UTC (rev 2763)
@@ -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;

Modified: upstream/trunk/lib/groupio.c
===================================================================
--- upstream/trunk/lib/groupio.c	2009-04-22 21:33:09 UTC (rev 2762)
+++ upstream/trunk/lib/groupio.c	2009-04-23 09:57:03 UTC (rev 2763)
@@ -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 @@
 		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 @@
  * 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 @@
 	}
 	new_members = (char **)malloc ( (members+1) * sizeof(char*) );
 	if (NULL == new_members) {
+		free (new_line);
 		errno = ENOMEM;
 		return NULL;
 	}
@@ -370,7 +373,7 @@
 {
 	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 @@
 		}
 		new->eptr = group_dup(gr->eptr);
 		if (NULL == new->eptr) {
+			free (new);
 			errno = ENOMEM;
 			return 0;
 		}

Modified: upstream/trunk/lib/gshadow_.h
===================================================================
--- upstream/trunk/lib/gshadow_.h	2009-04-22 21:33:09 UTC (rev 2762)
+++ upstream/trunk/lib/gshadow_.h	2009-04-23 09:57:03 UTC (rev 2763)
@@ -54,18 +54,18 @@
 #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 ();

Modified: upstream/trunk/lib/prototypes.h
===================================================================
--- upstream/trunk/lib/prototypes.h	2009-04-22 21:33:09 UTC (rev 2762)
+++ upstream/trunk/lib/prototypes.h	2009-04-23 09:57:03 UTC (rev 2763)
@@ -80,8 +80,8 @@
 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_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 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 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 @@
 #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 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 @@
                       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 *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);

Modified: upstream/trunk/lib/pwio.c
===================================================================
--- upstream/trunk/lib/pwio.c	2009-04-22 21:33:09 UTC (rev 2762)
+++ upstream/trunk/lib/pwio.c	2009-04-23 09:57:03 UTC (rev 2763)
@@ -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;
 

Modified: upstream/trunk/lib/sgroupio.c
===================================================================
--- upstream/trunk/lib/sgroupio.c	2009-04-22 21:33:09 UTC (rev 2762)
+++ upstream/trunk/lib/sgroupio.c	2009-04-23 09:57:03 UTC (rev 2763)
@@ -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 @@
 	return sg;
 }
 
-static void *gshadow_dup (const void *ent)
+static /*@null@*/ /*@only@*/void *gshadow_dup (const void *ent)
 {
 	const struct sgrp *sg = ent;
 

Modified: upstream/trunk/lib/shadowio.c
===================================================================
--- upstream/trunk/lib/shadowio.c	2009-04-22 21:33:09 UTC (rev 2762)
+++ upstream/trunk/lib/shadowio.c	2009-04-23 09:57:03 UTC (rev 2763)
@@ -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;
 

Modified: upstream/trunk/libmisc/cleanup.c
===================================================================
--- upstream/trunk/libmisc/cleanup.c	2009-04-22 21:33:09 UTC (rev 2762)
+++ upstream/trunk/libmisc/cleanup.c	2009-04-23 09:57:03 UTC (rev 2763)
@@ -75,7 +75,7 @@
 /*
  * add_cleanup - Add a cleanup_function to the cleanup_functions stack.
  */
-void add_cleanup (cleanup_function pcf, void *arg)
+void add_cleanup (cleanup_function pcf, /*@null@*/void *arg)
 {
 	unsigned int i;
 	assert (NULL != pcf);

Modified: upstream/trunk/libmisc/getgr_nam_gid.c
===================================================================
--- upstream/trunk/libmisc/getgr_nam_gid.c	2009-04-22 21:33:09 UTC (rev 2762)
+++ upstream/trunk/libmisc/getgr_nam_gid.c	2009-04-23 09:57:03 UTC (rev 2763)
@@ -44,7 +44,7 @@
  * The string may be a valid GID or a valid groupname.
  * If the group does not exist on the system, NULL is returned.
  */
-extern struct group *getgr_nam_gid (const char *grname)
+extern /*@null@*/struct group *getgr_nam_gid (const char *grname)
 {
 	long long int gid;
 	char *endptr;

Modified: upstream/trunk/libmisc/list.c
===================================================================
--- upstream/trunk/libmisc/list.c	2009-04-22 21:33:09 UTC (rev 2762)
+++ upstream/trunk/libmisc/list.c	2009-04-23 09:57:03 UTC (rev 2763)
@@ -43,7 +43,7 @@
  *	name, and if not present it is added to a freshly allocated
  *	list of users.
  */
-char **add_list (char **list, const char *member)
+/*@only@*/ /*@out@*/char **add_list (/*@returned@*/ /*@only@*/char **list, const char *member)
 {
 	int i;
 	char **tmp;
@@ -93,7 +93,7 @@
  *	list of users.
  */
 
-char **del_list (char **list, const char *member)
+/*@only@*/ /*@out@*/char **del_list (/*@returned@*/ /*@only@*/char **list, const char *member)
 {
 	int i, j;
 	char **tmp;
@@ -141,7 +141,7 @@
 	return tmp;
 }
 
-char **dup_list (char *const *list)
+/*@only@*/ /*@out@*/char **dup_list (char *const *list)
 {
 	int i;
 	char **tmp;
@@ -182,12 +182,13 @@
  * comma_to_list - convert comma-separated list to (char *) array
  */
 
-char **comma_to_list (const char *comma)
+/*@only@*/char **comma_to_list (const char *comma)
 {
 	char *members;
 	char **array;
 	int i;
-	char *cp, *cp2;
+	const char *cp;
+	char *cp2;
 
 	assert (NULL != comma);
 

Modified: upstream/trunk/libmisc/myname.c
===================================================================
--- upstream/trunk/libmisc/myname.c	2009-04-22 21:33:09 UTC (rev 2762)
+++ upstream/trunk/libmisc/myname.c	2009-04-23 09:57:03 UTC (rev 2763)
@@ -1,7 +1,7 @@
 /*
  * Copyright (c) 1996 - 1997, Marek Michałkiewicz
  * Copyright (c) 2003 - 2005, Tomasz Kłoczko
- * Copyright (c) 2007 - 2008, Nicolas François
+ * Copyright (c) 2007 - 2009, Nicolas François
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -41,7 +41,7 @@
 #include "defines.h"
 #include <pwd.h>
 #include "prototypes.h"
-struct passwd *get_my_pwent (void)
+/*@null@*/struct passwd *get_my_pwent (void)
 {
 	struct passwd *pw;
 	const char *cp = getlogin ();

Modified: upstream/trunk/libmisc/salt.c
===================================================================
--- upstream/trunk/libmisc/salt.c	2009-04-22 21:33:09 UTC (rev 2762)
+++ upstream/trunk/libmisc/salt.c	2009-04-23 09:57:03 UTC (rev 2763)
@@ -21,14 +21,14 @@
 
 /* local function prototypes */
 static void seedRNG (void);
-static char *gensalt (size_t salt_size);
+static /*@observer@*/const char *gensalt (size_t salt_size);
 #ifdef USE_SHA_CRYPT
 static size_t SHA_salt_size (void);
-static const char *SHA_salt_rounds (int *prefered_rounds);
+static /*@observer@*/const char *SHA_salt_rounds (/*@null@*/int *prefered_rounds);
 #endif /* USE_SHA_CRYPT */
 
 #ifndef HAVE_L64A
-static char *l64a(long value)
+static /*@observer@*/char *l64a(long value)
 {
 	static char buf[8];
 	char *s = buf;
@@ -104,7 +104,7 @@
 /*
  * Return a salt prefix specifying the rounds number for the SHA crypt methods.
  */
-static const char *SHA_salt_rounds (int *prefered_rounds)
+static /*@observer@*/const char *SHA_salt_rounds (/*@null@*/int *prefered_rounds)
 {
 	static char rounds_prefix[18];
 	long rounds;
@@ -168,7 +168,7 @@
 #define MAX_SALT_SIZE 16
 #define MIN_SALT_SIZE 8
 
-static char *gensalt (size_t salt_size)
+static /*@observer@*/const char *gensalt (size_t salt_size)
 {
 	static char salt[32];
 
@@ -202,7 +202,7 @@
  *  * For the SHA256 and SHA512 method, this specifies the number of rounds
  *    (if not NULL).
  */
-char *crypt_make_salt (const char *meth, void *arg)
+/*@observer@*/const char *crypt_make_salt (/*@null@*/const char *meth, /*@null@*/void *arg)
 {
 	/* Max result size for the SHA methods:
 	 *  +3		$5$

Modified: upstream/trunk/libmisc/xgetXXbyYY.c
===================================================================
--- upstream/trunk/libmisc/xgetXXbyYY.c	2009-04-22 21:33:09 UTC (rev 2762)
+++ upstream/trunk/libmisc/xgetXXbyYY.c	2009-04-23 09:57:03 UTC (rev 2763)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2007 - 2008, Nicolas François
+ * Copyright (c) 2007 - 2009, Nicolas François
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -64,7 +64,7 @@
 #define STRINGIZE(name) STRINGIZE1 (name)
 #define STRINGIZE1(name) #name
 
-LOOKUP_TYPE *XFUNCTION_NAME (ARG_TYPE ARG_NAME)
+/*@null@*/ /*@only@*/LOOKUP_TYPE *XFUNCTION_NAME (ARG_TYPE ARG_NAME)
 {
 #if HAVE_FUNCTION_R
 	LOOKUP_TYPE *result=NULL;

Modified: upstream/trunk/src/login.c
===================================================================
--- upstream/trunk/src/login.c	2009-04-22 21:33:09 UTC (rev 2762)
+++ upstream/trunk/src/login.c	2009-04-23 09:57:03 UTC (rev 2763)
@@ -123,11 +123,11 @@
 static void usage (void);
 static void setup_tty (void);
 static void process_flags (int argc, char *const *argv);
-static const char *get_failent_user (/*@returned@*/const char *user);
+static /*@observer@*/const char *get_failent_user (/*@returned@*/const char *user);
 static void update_utmp (const char *username,
                          const char *tty,
                          const char *hostname,
-                         const struct utmp *utent);
+                         /*@null@*/const struct utmp *utent);
 
 #ifndef USE_PAM
 static struct faillog faillog;
@@ -194,13 +194,13 @@
 		/* Make sure the values were valid.
 		 * getdef_num cannot validate this.
 		 */
-		if (erasechar != termio.c_cc[VERASE]) {
+		if (erasechar != (int) termio.c_cc[VERASE]) {
 			fprintf (stderr,
 			         _("configuration error - cannot parse %s value: '%d'"),
 			         "ERASECHAR", erasechar);
 			exit (1);
 		}
-		if (killchar != termio.c_cc[VKILL]) {
+		if (killchar != (int) termio.c_cc[VKILL]) {
 			fprintf (stderr,
 			         _("configuration error - cannot parse %s value: '%d'"),
 			         "KILLCHAR", killchar);
@@ -454,7 +454,7 @@
  * It is quite common to mistyped the password for username, and passwords
  * should not be logged.
  */
-static const char *get_failent_user (/*@returned@*/const char *user)
+static /*@observer@*/const char *get_failent_user (/*@returned@*/const char *user)
 {
 	const char *failent_user = "UNKNOWN";
 	bool log_unkfail_enab = getdef_bool("LOG_UNKFAIL_ENAB");
@@ -1000,7 +1000,7 @@
 			failed = true;
 		}
 		if (   !failed
-		    && !login_access (username, *hostname ? hostname : tty)) {
+		    && !login_access (username, ('\0' != *hostname) ? hostname : tty)) {
 			SYSLOG ((LOG_WARN, "LOGIN '%s' REFUSED %s",
 			         username, fromhost));
 			failed = true;




More information about the Pkg-shadow-commits mailing list