Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Third Party Openssl
提交
1ae0a83b
T
Third Party Openssl
项目概览
OpenHarmony
/
Third Party Openssl
9 个月 前同步成功
通知
8
Star
18
Fork
1
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
Third Party Openssl
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
1ae0a83b
编写于
4月 29, 2003
作者:
R
Richard Levitte
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add BUF_strndup() and BUF_memdup(). Not currently used, but I've code
that uses them that I'll commit in a few days.
上级
7ae46c67
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
37 addition
and
7 deletion
+37
-7
CHANGES
CHANGES
+6
-0
crypto/buffer/buf_err.c
crypto/buffer/buf_err.c
+3
-2
crypto/buffer/buffer.c
crypto/buffer/buffer.c
+24
-5
crypto/buffer/buffer.h
crypto/buffer/buffer.h
+4
-0
未找到文件。
CHANGES
浏览文件 @
1ae0a83b
...
@@ -4,6 +4,12 @@
...
@@ -4,6 +4,12 @@
Changes between 0.9.7a and 0.9.8 [xx XXX xxxx]
Changes between 0.9.7a and 0.9.8 [xx XXX xxxx]
*) Add the functions BUF_strndup() and BUF_memdup(). BUF_strndup()
works like BUF_strdup() but can be used to duplicate a portion of
a string. The copy gets NUL-terminated. BUF_memdup() duplicates
a memory area.
[Richard Levitte]
*) Add the function sk_find_ex() which works like sk_find(), but will
*) Add the function sk_find_ex() which works like sk_find(), but will
return an index to an element even if an exact match couldn't be
return an index to an element even if an exact match couldn't be
found. The index is guaranteed to point at the element where the
found. The index is guaranteed to point at the element where the
...
...
crypto/buffer/buf_err.c
浏览文件 @
1ae0a83b
/* crypto/buffer/buf_err.c */
/* crypto/buffer/buf_err.c */
/* ====================================================================
/* ====================================================================
* Copyright (c) 1999 The OpenSSL Project. All rights reserved.
* Copyright (c) 1999
-2003
The OpenSSL Project. All rights reserved.
*
*
* Redistribution and use in source and binary forms, with or without
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* modification, are permitted provided that the following conditions
...
@@ -61,15 +61,16 @@
...
@@ -61,15 +61,16 @@
#include <stdio.h>
#include <stdio.h>
#include <openssl/err.h>
#include <openssl/err.h>
#include <openssl/buffer.h>
#include <openssl/buffer.h>
#include <openssl/opensslconf.h>
/* To see if OPENSSL_NO_ERR is defined */
/* BEGIN ERROR CODES */
/* BEGIN ERROR CODES */
#ifndef OPENSSL_NO_ERR
#ifndef OPENSSL_NO_ERR
static
ERR_STRING_DATA
BUF_str_functs
[]
=
static
ERR_STRING_DATA
BUF_str_functs
[]
=
{
{
{
ERR_PACK
(
0
,
BUF_F_BUF_MEMDUP
,
0
),
"BUF_memdup"
},
{
ERR_PACK
(
0
,
BUF_F_BUF_MEM_GROW
,
0
),
"BUF_MEM_grow"
},
{
ERR_PACK
(
0
,
BUF_F_BUF_MEM_GROW
,
0
),
"BUF_MEM_grow"
},
{
ERR_PACK
(
0
,
BUF_F_BUF_MEM_NEW
,
0
),
"BUF_MEM_new"
},
{
ERR_PACK
(
0
,
BUF_F_BUF_MEM_NEW
,
0
),
"BUF_MEM_new"
},
{
ERR_PACK
(
0
,
BUF_F_BUF_STRDUP
,
0
),
"BUF_strdup"
},
{
ERR_PACK
(
0
,
BUF_F_BUF_STRDUP
,
0
),
"BUF_strdup"
},
{
ERR_PACK
(
0
,
BUF_F_BUF_STRNDUP
,
0
),
"BUF_strndup"
},
{
0
,
NULL
}
{
0
,
NULL
}
};
};
...
...
crypto/buffer/buffer.c
浏览文件 @
1ae0a83b
...
@@ -163,23 +163,42 @@ int BUF_MEM_grow_clean(BUF_MEM *str, int len)
...
@@ -163,23 +163,42 @@ int BUF_MEM_grow_clean(BUF_MEM *str, int len)
}
}
char
*
BUF_strdup
(
const
char
*
str
)
char
*
BUF_strdup
(
const
char
*
str
)
{
if
(
str
==
NULL
)
return
(
NULL
);
return
BUF_strndup
(
str
,
strlen
(
str
));
}
char
*
BUF_strndup
(
const
char
*
str
,
size_t
siz
)
{
{
char
*
ret
;
char
*
ret
;
int
n
;
if
(
str
==
NULL
)
return
(
NULL
);
if
(
str
==
NULL
)
return
(
NULL
);
n
=
strlen
(
str
);
ret
=
OPENSSL_malloc
(
siz
+
1
);
ret
=
OPENSSL_malloc
(
n
+
1
);
if
(
ret
==
NULL
)
if
(
ret
==
NULL
)
{
{
BUFerr
(
BUF_F_BUF_STRDUP
,
ERR_R_MALLOC_FAILURE
);
BUFerr
(
BUF_F_BUF_STR
N
DUP
,
ERR_R_MALLOC_FAILURE
);
return
(
NULL
);
return
(
NULL
);
}
}
memcpy
(
ret
,
str
,
n
+
1
);
BUF_strlcpy
(
ret
,
str
,
siz
+
1
);
return
(
ret
);
return
(
ret
);
}
}
void
*
BUF_memdup
(
const
void
*
data
,
size_t
siz
)
{
void
*
ret
;
if
(
data
==
NULL
)
return
(
NULL
);
ret
=
OPENSSL_malloc
(
siz
);
if
(
ret
==
NULL
)
{
BUFerr
(
BUF_F_BUF_MEMDUP
,
ERR_R_MALLOC_FAILURE
);
return
(
NULL
);
}
return
memcpy
(
ret
,
data
,
siz
);
}
size_t
BUF_strlcpy
(
char
*
dst
,
const
char
*
src
,
size_t
size
)
size_t
BUF_strlcpy
(
char
*
dst
,
const
char
*
src
,
size_t
size
)
{
{
size_t
l
=
0
;
size_t
l
=
0
;
...
...
crypto/buffer/buffer.h
浏览文件 @
1ae0a83b
...
@@ -78,6 +78,8 @@ void BUF_MEM_free(BUF_MEM *a);
...
@@ -78,6 +78,8 @@ void BUF_MEM_free(BUF_MEM *a);
int
BUF_MEM_grow
(
BUF_MEM
*
str
,
int
len
);
int
BUF_MEM_grow
(
BUF_MEM
*
str
,
int
len
);
int
BUF_MEM_grow_clean
(
BUF_MEM
*
str
,
int
len
);
int
BUF_MEM_grow_clean
(
BUF_MEM
*
str
,
int
len
);
char
*
BUF_strdup
(
const
char
*
str
);
char
*
BUF_strdup
(
const
char
*
str
);
char
*
BUF_strndup
(
const
char
*
str
,
size_t
siz
);
void
*
BUF_memdup
(
const
void
*
data
,
size_t
siz
);
/* safe string functions */
/* safe string functions */
size_t
BUF_strlcpy
(
char
*
dst
,
const
char
*
src
,
size_t
siz
);
size_t
BUF_strlcpy
(
char
*
dst
,
const
char
*
src
,
size_t
siz
);
...
@@ -93,9 +95,11 @@ void ERR_load_BUF_strings(void);
...
@@ -93,9 +95,11 @@ void ERR_load_BUF_strings(void);
/* Error codes for the BUF functions. */
/* Error codes for the BUF functions. */
/* Function codes. */
/* Function codes. */
#define BUF_F_BUF_MEMDUP 103
#define BUF_F_BUF_MEM_GROW 100
#define BUF_F_BUF_MEM_GROW 100
#define BUF_F_BUF_MEM_NEW 101
#define BUF_F_BUF_MEM_NEW 101
#define BUF_F_BUF_STRDUP 102
#define BUF_F_BUF_STRDUP 102
#define BUF_F_BUF_STRNDUP 104
/* Reason codes. */
/* Reason codes. */
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录