Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
86fad0e0
D
dragonwell8_jdk
项目概览
openanolis
/
dragonwell8_jdk
通知
4
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
dragonwell8_jdk
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
86fad0e0
编写于
12月 11, 2012
作者:
D
dingxmin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
6512101: Incorrect encoding in NetworkInterface.getDisplayName()
Reviewed-by: chegar, dsamersoff
上级
2d73a0ab
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
34 addition
and
4 deletion
+34
-4
src/windows/native/java/net/NetworkInterface.c
src/windows/native/java/net/NetworkInterface.c
+34
-4
未找到文件。
src/windows/native/java/net/NetworkInterface.c
浏览文件 @
86fad0e0
...
...
@@ -178,7 +178,7 @@ int enumInterfaces(JNIEnv *env, netif **netifPP)
int
count
;
netif
*
netifP
;
DWORD
i
;
int
lo
=
0
,
eth
=
0
,
tr
=
0
,
fddi
=
0
,
ppp
=
0
,
sl
=
0
,
wlan
=
0
,
net
=
0
;
int
lo
=
0
,
eth
=
0
,
tr
=
0
,
fddi
=
0
,
ppp
=
0
,
sl
=
0
,
wlan
=
0
,
net
=
0
,
wlen
=
0
;
/*
* Ask the IP Helper library to enumerate the adapters
...
...
@@ -260,8 +260,17 @@ int enumInterfaces(JNIEnv *env, netif **netifPP)
*/
curr
=
(
netif
*
)
calloc
(
1
,
sizeof
(
netif
));
if
(
curr
!=
NULL
)
{
wlen
=
MultiByteToWideChar
(
CP_OEMCP
,
0
,
ifrowP
->
bDescr
,
ifrowP
->
dwDescrLen
,
NULL
,
0
);
if
(
wlen
==
0
)
{
// MultiByteToWideChar should not fail
// But in rare case it fails, we allow 'char' to be displayed
curr
->
displayName
=
(
char
*
)
malloc
(
ifrowP
->
dwDescrLen
+
1
);
}
else
{
curr
->
displayName
=
(
wchar_t
*
)
malloc
(
wlen
*
(
sizeof
(
wchar_t
))
+
1
);
}
curr
->
name
=
(
char
*
)
malloc
(
strlen
(
dev_name
)
+
1
);
curr
->
displayName
=
(
char
*
)
malloc
(
ifrowP
->
dwDescrLen
+
1
);
if
(
curr
->
name
==
NULL
||
curr
->
displayName
==
NULL
)
{
if
(
curr
->
name
)
free
(
curr
->
name
);
...
...
@@ -282,8 +291,29 @@ int enumInterfaces(JNIEnv *env, netif **netifPP)
* 32-bit numbers as index values.
*/
strcpy
(
curr
->
name
,
dev_name
);
strncpy
(
curr
->
displayName
,
ifrowP
->
bDescr
,
ifrowP
->
dwDescrLen
);
curr
->
displayName
[
ifrowP
->
dwDescrLen
]
=
'\0'
;
if
(
wlen
==
0
)
{
// display char type in case of MultiByteToWideChar failure
strncpy
(
curr
->
displayName
,
ifrowP
->
bDescr
,
ifrowP
->
dwDescrLen
);
curr
->
displayName
[
ifrowP
->
dwDescrLen
]
=
'\0'
;
}
else
{
// call MultiByteToWideChar again to fill curr->displayName
// it should not fail, because we have called it once before
if
(
MultiByteToWideChar
(
CP_OEMCP
,
0
,
ifrowP
->
bDescr
,
ifrowP
->
dwDescrLen
,
curr
->
displayName
,
wlen
)
==
0
)
{
JNU_ThrowByName
(
env
,
"java/lang/Error"
,
"Cannot get multibyte char for interface display name"
);
free_netif
(
netifP
);
free
(
tableP
);
free
(
curr
->
name
);
free
(
curr
->
displayName
);
free
(
curr
);
return
-
1
;
}
else
{
curr
->
displayName
[
wlen
*
(
sizeof
(
wchar_t
))]
=
'\0'
;
curr
->
dNameIsUnicode
=
TRUE
;
}
}
curr
->
dwIndex
=
ifrowP
->
dwIndex
;
curr
->
ifType
=
ifrowP
->
dwType
;
curr
->
index
=
GetFriendlyIfIndex
(
ifrowP
->
dwIndex
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录