ソースを参照

vccd: tested by valgrind

intirain 4 年 前
親
コミット
b5668eff93
5 ファイル変更、14 行追加、4 行削除
  1. 1 1
      Makefile
  2. 2 2
      include/vcc/version.h
  3. 2 0
      main.c
  4. 6 0
      users.c
  5. 3 1
      vcc.c

+ 1 - 1
Makefile

@@ -1,6 +1,6 @@
 VCCD_MAJOR 		= 1
 VCCD_MINOR 		= 8
-VCCD_PATCH 		= 0
+VCCD_PATCH 		= 1
 VCCD_STR 		= -rc 
 
 VCCD_COMPILE_TIME 	= $(shell date)

+ 2 - 2
include/vcc/version.h

@@ -1,2 +1,2 @@
-#define VCCD_VERSION "vccd 1.8.0 Fri Apr  8 20:44:09 CST 2022 root"
-#define VCCD_SEMVER "vccd 1.8.0-rc "
+#define VCCD_VERSION "vccd 1.8.1 Sat Apr 16 21:37:32 CST 2022 root"
+#define VCCD_SEMVER "vccd 1.8.1-rc "

+ 2 - 0
main.c

@@ -137,6 +137,8 @@ static int init_socket(void) {
 		exit(1);
 	}
 
+	memset(fds, 0, sizeof(struct pollfd) * POLLFDS);
+
 	for (i = 0; i < POLLFDS; i++) 
 		fds[i].fd = -1;
 

+ 6 - 0
users.c

@@ -56,6 +56,8 @@ int users_init(void) {
 		exit(1);
 	}
 
+	memset(vccd_dir, 0, PATH_MAX);
+
 	if (unlikely(read(fdt, vccd_dir, PATH_MAX) < 0)) {
 		perror("read()");
 
@@ -185,6 +187,9 @@ int do_user_login(int fd, struct vcc_request *req) {
 		return 1;
 	}
 
+	memset(out, 0, sizeof(struct vcc_request));
+	memset(usr, 0, sizeof(struct user));
+
 	out->magic = htonl(VCC_MAGIC);
 	out->reqtype = htonl(REQ_CTL_LOGIN);
 
@@ -228,6 +233,7 @@ int do_user_login(int fd, struct vcc_request *req) {
 		return 1;
 	}
 
+	memset(t, 0, 128);
 	klist_init(n);
 
 	n->value = fd;

+ 3 - 1
vcc.c

@@ -176,6 +176,8 @@ int vcc_message_broadcast(char *msg, char *usrname, int except_fd, int flags) {
 			continue;
 		}
 
+		memset(req, 0, sizeof(struct vcc_request));
+
 		req->magic = htonl(VCC_MAGIC);
 		req->reqtype = htonl(REQ_MSG_NEW);
 		req->uid = 0;
@@ -184,7 +186,7 @@ int vcc_message_broadcast(char *msg, char *usrname, int except_fd, int flags) {
 		/* no htonl(), because we didn't ntohl() */
 		req->flags = flags;
 
-		memcpy(req->msg, msg, MSG_SIZE);
+		strncpy(req->msg, msg, MSG_SIZE);
 		strncpy(req->usrname, usrname, USRNAME_SIZE);
 
 		vcc_send_req(n, req);