HADOOP-9635. Fix potential stack overflow in DomainSocket.c (V. Karthik Kumar via cmccabe)

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1491927 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Colin McCabe 2013-06-11 19:56:25 +00:00
parent 6f59922e9d
commit 0c88f38be8
2 changed files with 6 additions and 3 deletions

View File

@ -276,12 +276,13 @@ JNIEnv *env, jclass clazz, jobject jstr, jint skipComponents)
jthrowable jthr = NULL;
utfLength = (*env)->GetStringUTFLength(env, jstr);
if (utfLength > sizeof(path)) {
if (utfLength > (sizeof(path)-1)) {
jthr = newIOException(env, "path is too long! We expected a path "
"no longer than %zd UTF-8 bytes.", sizeof(path));
"no longer than %zd UTF-8 bytes.", (sizeof(path)-1));
goto done;
}
(*env)->GetStringUTFRegion(env, jstr, 0, utfLength, path);
path [ utfLength ] = 0;
jthr = (*env)->ExceptionOccurred(env);
if (jthr) {
(*env)->ExceptionClear(env);
@ -305,7 +306,7 @@ JNIEnv *env, jclass clazz, jobject jstr, jint skipComponents)
// be a directory. (If it is a directory, we will fail to create the socket
// later with EISDIR or similar.)
for (check[0] = '/', check[1] = '\0', rest = path, token = "";
token && rest[0];
token && rest && rest[0];
token = strtok_r(rest, "/", &rest)) {
if (strcmp(check, "/") != 0) {
// If the previous directory we checked was '/', we skip appending another

View File

@ -123,6 +123,8 @@ Trunk (Unreleased)
OPTIMIZATIONS
BUG FIXES
HADOOP-9635 Fix potential Stack Overflow in DomainSocket.c (V. Karthik Kumar
via cmccabe)
HDFS-2299. TestOfflineEditsViewer is failing on trunk. (Uma Maheswara Rao G
via atm)