Commit 8c580685acce28b315d626e327e68287473b27b0

Stefan Sperling 2018-04-22T15:40:59

treat unexpected message from unpriv processes as error

diff --git a/include/got_error.h b/include/got_error.h
index 92dd8ec..8c6c150 100644
--- a/include/got_error.h
+++ b/include/got_error.h
@@ -52,6 +52,7 @@
 #define GOT_ERR_PRIVSEP_LEN	36
 #define GOT_ERR_PRIVSEP_PIPE	37
 #define GOT_ERR_PRIVSEP_NO_FD	38
+#define GOT_ERR_PRIVSEP_MSG	39
 
 static const struct got_error {
 	int code;
@@ -93,6 +94,7 @@ static const struct got_error {
 				"from unprivileged process" },
 	{ GOT_ERR_PRIVSEP_PIPE,	"unprivileged process closed pipe" },
 	{ GOT_ERR_PRIVSEP_NO_FD,"out of file descriptors for privsep" },
+	{ GOT_ERR_PRIVSEP_MSG,"unexpected message from unprivileged process" },
 };
 
 /*
diff --git a/lib/privsep.c b/lib/privsep.c
index 60217e1..3638155 100644
--- a/lib/privsep.c
+++ b/lib/privsep.c
@@ -201,6 +201,9 @@ got_privsep_recv_obj(struct got_object **obj, struct imsgbuf *ibuf)
 			/* TODO: Handle deltas */
 		}
 		break;
+	default:
+		err = got_error(GOT_ERR_PRIVSEP_MSG);
+		break;
 	}
 
 	imsg_free(&imsg);