<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>change log for rtems (2010-09-08)</title>
</head>
<body text='#000000' bgcolor='#ffffff'>
<a name='cs1'></a>
<table border='0' cellspacing='0' cellpadding='5' width='100%' bgcolor='#eeeeee'>
<tr><td colspan='3' bgcolor='#dddddd'>
<font color='#bb2222'><strong>sh</strong></font>
</td></tr>
<tr><td colspan='3' bgcolor='#dddddd'><pre>2010-09-08 Sebastian Huber <sebastian.huber@embedded-brains.de>
PR 1698/cpukit
* libcsupport/src/privateenv.c: Check return values of
rtems_filesystem_evaluate_path().
</pre></td></tr>
<tr><td width='1%'><a href="http://www.rtems.com/cgi-bin/viewcvs.cgi//rtems/cpukit/ChangeLog.diff?r1=text&tr1=1.2623&r2=text&tr2=1.2624&diff_format=h">M</a></td><td width='1%'>1.2624</td><td width='100%'>cpukit/ChangeLog</td></tr>
<tr><td width='1%'><a href="http://www.rtems.com/cgi-bin/viewcvs.cgi//rtems/cpukit/libcsupport/src/privateenv.c.diff?r1=text&tr1=1.16&r2=text&tr2=1.17&diff_format=h">M</a></td><td width='1%'>1.17</td><td width='100%'>cpukit/libcsupport/src/privateenv.c</td></tr>
</table>
<pre>
<font color='#006600'>diff -u rtems/cpukit/ChangeLog:1.2623 rtems/cpukit/ChangeLog:1.2624
--- rtems/cpukit/ChangeLog:1.2623 Wed Sep 1 06:12:37 2010
+++ rtems/cpukit/ChangeLog Wed Sep 8 02:31:28 2010
</font><font color='#997700'>@@ -1,3 +1,9 @@
</font><font color='#000088'>+2010-09-08 Sebastian Huber <sebastian.huber@embedded-brains.de>
+
+ PR 1698/cpukit
+ * libcsupport/src/privateenv.c: Check return values of
+ rtems_filesystem_evaluate_path().
+
</font> 2010-09-01 Ralf Corsépius <ralf.corsepius@rtems.org>
PR 1696/networking:
<font color='#006600'>diff -u rtems/cpukit/libcsupport/src/privateenv.c:1.16 rtems/cpukit/libcsupport/src/privateenv.c:1.17
--- rtems/cpukit/libcsupport/src/privateenv.c:1.16 Sun Aug 29 14:49:52 2010
+++ rtems/cpukit/libcsupport/src/privateenv.c Wed Sep 8 02:31:28 2010
</font><font color='#997700'>@@ -21,16 +21,8 @@
</font>
#include <rtems.h>
#include <rtems/chain.h>
<font color='#880000'>-#include <rtems/libio.h>
</font> #include <rtems/libio_.h>
<font color='#880000'>-#if defined(RTEMS_DEBUG)
- #define CHECK_STATUS(_x) assert((_x) == )
- #include <assert.h>
-#else
- #define CHECK_STATUS(_x) _x
-#endif
-
</font> /* cleanup a user environment
* NOTE: this must be called with
* thread dispatching disabled!
<font color='#997700'>@@ -53,11 +45,20 @@
</font>
rtems_status_code rtems_libio_set_private_env(void)
{
<font color='#880000'>- rtems_status_code sc;
- rtems_id task_id;
- rtems_filesystem_location_info_t loc;
-
- task_id = rtems_task_self();
</font><font color='#000088'>+ rtems_status_code sc = RTEMS_SUCCESSFUL;
+ rtems_id task_id = rtems_task_self();
+ rtems_filesystem_location_info_t root_loc;
+ rtems_filesystem_location_info_t current_loc;
+ rtems_user_env_t *new_env = NULL;
+ int rv = 0;
+
+ rv = rtems_filesystem_evaluate_path("/", 1, 0, &root_loc, 0);
+ if (rv != 0)
+ goto error_0;
+
+ rv = rtems_filesystem_evaluate_path("/", 1, 0, ¤t_loc, 0);
+ if (rv != 0)
+ goto error_1;
</font>
/*<span style="background-color: #FF0000"> </span>
* Malloc is necessary whenever the current task does not
<font color='#997700'>@@ -72,14 +73,16 @@
</font> * if( rtems_current_user_env->task_id != task_id ) {
*/
<font color='#880000'>- if (rtems_current_user_env==&rtems_global_user_env ||<span style="background-color: #FF0000"> </span>
- rtems_current_user_env->task_id != task_id ) {
- rtems_user_env_t *tmp = malloc(sizeof(rtems_user_env_t));
- if (!tmp)
- return RTEMS_NO_MEMORY;
</font><font color='#000088'>+ if (
+ rtems_current_user_env == &rtems_global_user_env
+ || rtems_current_user_env->task_id != task_id
+ ) {
+ new_env = malloc(sizeof(rtems_user_env_t));
+ if (new_env == NULL)
+ goto error_2;
</font>
#ifdef HAVE_USERENV_REFCNT
<font color='#880000'>- tmp->refcnt = 1;
</font><font color='#000088'>+ new_env->refcnt = 1;
</font> #endif
sc = rtems_task_variable_add(
<font color='#997700'>@@ -87,35 +90,39 @@
</font> (void*)&rtems_current_user_env,
(void(*)(void *))free_user_env
);
<font color='#880000'>- if (sc != RTEMS_SUCCESSFUL) {
- /* don't use free_user_env because the pathlocs are
- * not initialized yet
- */
- free(tmp);
- return sc;
- }
- rtems_current_user_env = tmp;
</font><font color='#000088'>+ if (sc != RTEMS_SUCCESSFUL)
+ goto error_3;
+
+ rtems_current_user_env = new_env;
</font> }
<font color='#880000'>- *rtems_current_user_env = rtems_global_user_env; /* get the global values*/
- rtems_current_user_env->task_id=task_id; /* mark the local values*/
</font><font color='#000088'>+ /* Inherit the global values */
+ *rtems_current_user_env = rtems_global_user_env;
</font>
<font color='#880000'>- /* Clone the pathlocs. In contrast to most other code we must _not_
- * free the original locs because what we are trying to do here is forking
- * off clones. The reason is a pathloc can be allocated by the file system
- * and needs to be freed when deleting the environment.
- *
- * NOTE: Evaluation should always work so only check status when debug
- * is enabled.
</font><font color='#000088'>+ rtems_current_user_env->task_id = task_id;
+
+ /*
+ * Clone the pathlocs. In contrast to most other code we must _not_ free the
+ * original locs because what we are trying to do here is forking off clones.
+ * The reason is a pathloc can be allocated by the file system and needs to
+ * be freed when deleting the environment.
</font> */
<font color='#000088'>+ rtems_filesystem_root = root_loc;
+ rtems_filesystem_current = current_loc;
+
+ return RTEMS_SUCCESSFUL;
</font>
<font color='#880000'>- CHECK_STATUS( rtems_filesystem_evaluate_path("/", 1, 0, &loc, 0) );
- rtems_filesystem_root = loc;
</font><font color='#000088'>+error_3:
+ free(new_env);
</font>
<font color='#880000'>- CHECK_STATUS( rtems_filesystem_evaluate_path("/", 1, 0, &loc, 0) );
- rtems_filesystem_current = loc;
</font><font color='#000088'>+error_2:
+ rtems_filesystem_freenode(¤t_loc);
</font>
<font color='#880000'>- return RTEMS_SUCCESSFUL;
</font><font color='#000088'>+error_1:
+ rtems_filesystem_freenode(&root_loc);
+
+error_0:
+ return RTEMS_NO_MEMORY;
</font> }
/*
</pre>
<p> </p>
<p>--<br />
<small>Generated by <a href="http://www.codewiz.org/projects/index.html#loginfo">Deluxe Loginfo</a> 2.122 by Bernardo Innocenti <bernie@develer.com></small></p>
</body>
</html>