Author: iratqq
Date: Sun Mar 2 07:33:55 2008
New Revision: 5270
Modified:
trunk/fep/udsock.c
trunk/uim/prime.c
trunk/uim/uim-helper.c
trunk/uim/uim-posix.c
Log:
* uim/uim-posix.c
(uim_get_user_name, uim_get_home_directory, uim_get_config_path):
- Check truncation.
* uim/uim-helper.c (uim_helper_get_pathname):
- Ditto.
* uim/prime.c (prime_get_ud_path):
- Ditto.
* fep/udsock.c (get_ud_path):
- Ditto.
Modified: trunk/fep/udsock.c
==============================================================================
--- trunk/fep/udsock.c (original)
+++ trunk/fep/udsock.c Sun Mar 2 07:33:55 2008
@@ -80,10 +80,15 @@
return UIM_FALSE;
}
- strlcat(path, "/fep", len);
+ if (strlcat(path, "/fep", len) >= (size_t)len) {
+ path[0] = '\0';
+ return UIM_FALSE;
+ }
- if (!uim_check_dir(path))
+ if (!uim_check_dir(path)) {
+ path[0] = '\0';
return UIM_FALSE;
+ }
return UIM_TRUE;
}
Modified: trunk/uim/prime.c
==============================================================================
--- trunk/uim/prime.c (original)
+++ trunk/uim/prime.c Sun Mar 2 07:33:55 2008
@@ -116,21 +116,23 @@
if (len <= 0)
return UIM_FALSE;
- if (!uim_get_config_path(prime_path, len, !uim_helper_is_setugid())) {
- prime_path[0] = '\0';
- return UIM_FALSE;
- }
+ if (!uim_get_config_path(prime_path, len, !uim_helper_is_setugid()))
+ goto path_error;
- strlcat(prime_path, "/socket", len);
+ if (strlcat(prime_path, "/socket", len) >= (size_t)len)
+ goto path_error;
- if (!uim_check_dir(prime_path)) {
- prime_path[0] = '\0';
- return UIM_FALSE;
- }
+ if (!uim_check_dir(prime_path))
+ goto path_error;
- strlcat(prime_path, "/uim-prime", len);
+ if (strlcat(prime_path, "/uim-prime", len) >= (size_t)len)
+ goto path_error;
return UIM_TRUE;
+
+ path_error:
+ prime_path[0] = '\0';
+ return UIM_FALSE;
}
static void
Modified: trunk/uim/uim-helper.c
==============================================================================
--- trunk/uim/uim-helper.c (original)
+++ trunk/uim/uim-helper.c Sun Mar 2 07:33:55 2008
@@ -172,44 +172,49 @@
if (len <= 0)
return UIM_FALSE;
- if (UIM_CATCH_ERROR_BEGIN()) {
- helper_path[0] = '\0';
+ if (UIM_CATCH_ERROR_BEGIN())
return UIM_FALSE;
- }
pw = getpwuid(getuid());
if (!pw) {
- uim_fatal_error("uim_helper_get_pathname()");
endpwent();
- helper_path[0] = '\0';
- return UIM_FALSE;
+ goto path_error;
}
- strlcpy(helper_path, pw->pw_dir, len);
- strlcat(helper_path, "/.uim.d", len);
+ if (strlcpy(helper_path, pw->pw_dir, len) >= (size_t)len) {
+ endpwent();
+ goto path_error;
+ }
+ if (strlcat(helper_path, "/.uim.d", len) >= (size_t)len) {
+ endpwent();
+ goto path_error;
+ }
endpwent();
/* check ~/.uim.d/ */
- if (!check_dir(helper_path)) {
- uim_fatal_error("uim_helper_get_pathname()");
- helper_path[0] = '\0';
- return UIM_FALSE;
- }
+ if (!check_dir(helper_path))
+ goto path_error;
/* check ~/.uim.d/socket/ */
- strlcat(helper_path, "/socket", len);
+ if (strlcat(helper_path, "/socket", len) >= (size_t)len)
+ goto path_error;
- if (!check_dir(helper_path)) {
- uim_fatal_error("uim_helper_get_pathname()");
- helper_path[0] = '\0';
- return UIM_FALSE;
- }
+ if (!check_dir(helper_path))
+ goto path_error;
- strlcat(helper_path, "/uim-helper", len);
+ if (strlcat(helper_path, "/uim-helper", len) >= (size_t)len)
+ goto path_error;
UIM_CATCH_ERROR_END();
return UIM_TRUE;
+
+ path_error:
+ uim_fatal_error("uim_helper_get_pathname()");
+ helper_path[0] = '\0';
+
+ UIM_CATCH_ERROR_END();
+ return UIM_FALSE;
}
int
Modified: trunk/uim/uim-posix.c
==============================================================================
--- trunk/uim/uim-posix.c (original)
+++ trunk/uim/uim-posix.c Sun Mar 2 07:33:55 2008
@@ -60,7 +60,11 @@
name[0] = '\0';
return UIM_FALSE;
}
- strlcpy(name, pw->pw_name, len);
+ if (strlcpy(name, pw->pw_name, len) >= (size_t)len) {
+ name[0] = '\0';
+ endpwent();
+ return UIM_FALSE;
+ }
endpwent();
return UIM_TRUE;
}
@@ -88,7 +92,11 @@
home[0] = '\0';
return UIM_FALSE;
}
- strlcpy(home, pw->pw_dir, len);
+ if (strlcpy(home, pw->pw_dir, len) >= (size_t)len) {
+ home[0] = '\0';
+ endpwent();
+ return UIM_FALSE;
+ }
endpwent();
return UIM_TRUE;
}
@@ -152,7 +160,8 @@
if (!home_env)
return UIM_FALSE;
- strlcpy(home, home_env, sizeof(home));
+ if (strlcpy(home, home_env, sizeof(home)) >= sizeof(home))
+ return UIM_FALSE;
}
if (snprintf(path, len, "%s/.uim.d", home) == -1)