Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F171188756
D59521.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
D59521.diff
View Options
diff --git a/sbin/hastd/proto.c b/sbin/hastd/proto.c
--- a/sbin/hastd/proto.c
+++ b/sbin/hastd/proto.c
@@ -281,7 +281,6 @@
int
proto_connection_send(const struct proto_conn *conn, struct proto_conn *mconn)
{
- const char *protoname;
int ret, fd;
PJDLOG_ASSERT(conn != NULL);
@@ -293,11 +292,9 @@
PJDLOG_ASSERT(mconn->pc_proto != NULL);
fd = proto_descriptor(mconn);
PJDLOG_ASSERT(fd >= 0);
- protoname = mconn->pc_proto->prt_name;
- PJDLOG_ASSERT(protoname != NULL);
ret = conn->pc_proto->prt_send(conn->pc_ctx,
- (const unsigned char *)protoname, strlen(protoname) + 1, fd);
+ mconn->pc_proto->prt_name, sizeof(mconn->pc_proto->prt_name), fd);
proto_close(mconn);
if (ret != 0) {
errno = ret;
@@ -310,7 +307,7 @@
proto_connection_recv(const struct proto_conn *conn, bool client,
struct proto_conn **newconnp)
{
- char protoname[128];
+ char protoname[sizeof(conn->pc_proto->prt_name)];
struct proto *proto;
struct proto_conn *newconn;
int ret, fd;
@@ -321,10 +318,8 @@
PJDLOG_ASSERT(conn->pc_proto->prt_recv != NULL);
PJDLOG_ASSERT(newconnp != NULL);
- bzero(protoname, sizeof(protoname));
-
- ret = conn->pc_proto->prt_recv(conn->pc_ctx, (unsigned char *)protoname,
- sizeof(protoname) - 1, &fd);
+ ret = conn->pc_proto->prt_recv(conn->pc_ctx, protoname,
+ sizeof(protoname), &fd);
if (ret != 0) {
errno = ret;
return (-1);
@@ -333,7 +328,7 @@
PJDLOG_ASSERT(fd >= 0);
TAILQ_FOREACH(proto, &protos, prt_next) {
- if (strcmp(proto->prt_name, protoname) == 0)
+ if (memcmp(proto->prt_name, protoname, sizeof(protoname)) == 0)
break;
}
if (proto == NULL) {
diff --git a/sbin/hastd/proto_impl.h b/sbin/hastd/proto_impl.h
--- a/sbin/hastd/proto_impl.h
+++ b/sbin/hastd/proto_impl.h
@@ -53,7 +53,7 @@
typedef void prt_close_t(void *);
struct proto {
- const char *prt_name;
+ char prt_name[4];
prt_client_t *prt_client;
prt_connect_t *prt_connect;
prt_connect_wait_t *prt_connect_wait;
diff --git a/sbin/hastd/proto_socketpair.c b/sbin/hastd/proto_socketpair.c
--- a/sbin/hastd/proto_socketpair.c
+++ b/sbin/hastd/proto_socketpair.c
@@ -219,7 +219,7 @@
}
static struct proto sp_proto = {
- .prt_name = "socketpair",
+ .prt_name = "skp",
.prt_client = sp_client,
.prt_send = sp_send,
.prt_recv = sp_recv,
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Sep 10, 9:13 AM (17 h, 38 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
38638879
Default Alt Text
D59521.diff (2 KB)
Attached To
Mode
D59521: hastd: Use fixed-length protocol names
Attached
Detach File
Event Timeline
Log In to Comment