cvs commit: src/lib/libc/posix1e acl_delete_entry.c

Stefan Farfeleder stefan at fafoe.narf.at
Tue Jan 6 12:18:12 PST 2004


On Tue, Jan 06, 2004 at 10:43:31AM -0800, Jacques Vidrine wrote:
> nectar      2004/01/06 10:43:31 PST
> 
>   FreeBSD src repository
> 
>   Modified files:
>     lib/libc/posix1e     acl_delete_entry.c 
>   Log:
>   Avoid undefined behavior:
>     foo[i] = bar[++i];  /* Which operator [] will be evaluated first? */
>   
>   Revision  Changes    Path
>   1.6       +2 -2      src/lib/libc/posix1e/acl_delete_entry.c

@@ -61,9 +61,9 @@ acl_delete_entry(acl_t acl, acl_entry_t 
 		if ((acl->ats_acl.acl_entry[i].ae_tag == entry_d->ae_tag) &&
 		    (acl->ats_acl.acl_entry[i].ae_id == entry_d->ae_id)) {
 			/* ...shift the remaining entries... */
-			while (i < acl->ats_acl.acl_cnt - 1)
+			for (; i < acl->ats_acl.acl_cnt - 1; ++i)
 				acl->ats_acl.acl_entry[i] =
-				    acl->ats_acl.acl_entry[++i];
+				    acl->ats_acl.acl_entry[i];

I think that last assignment should read:

acl->ats_acl.acl_entry[i] = acl->ats_acl.acl_entry[i + 1];

Using memmove() instead might be a good idea too.

Cheers,
Stefan


More information about the cvs-src mailing list