Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F110741241
D47625.id146802.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
D47625.id146802.diff
View Options
diff --git a/sbin/devd/tests/client_test.c b/sbin/devd/tests/client_test.c
--- a/sbin/devd/tests/client_test.c
+++ b/sbin/devd/tests/client_test.c
@@ -22,15 +22,14 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-#include <stdbool.h>
-#include <stdio.h>
-
#include <sys/param.h>
-#include <sys/types.h>
#include <sys/socket.h>
#include <sys/un.h>
+#include <stdbool.h>
+#include <stdio.h>
+#include <stdlib.h>
+
#include <atf-c.h>
const char create_pat[] = "!system=DEVFS subsystem=CDEV type=CREATE cdev=md";
@@ -134,29 +133,37 @@
ATF_TC_WITHOUT_HEAD(stream);
ATF_TC_BODY(stream, tc)
{
+ char *event;
int s;
bool got_create_event = false;
bool got_destroy_event = false;
- ssize_t len = 0;
+ size_t len = 0, sz;
s = common_setup(SOCK_STREAM, "/var/run/devd.pipe");
+
+ /*
+ * Use a large buffer: we're reading from a stream socket so can't rely
+ * on record boundaries. Instead, we just keep appending to the buffer.
+ */
+ sz = 1024 * 1024;
+ event = malloc(sz);
+ ATF_REQUIRE(event != NULL);
+
/*
* Loop until both events are detected on the same or different reads.
* There may be extra events due to unrelated system activity.
* If we never get both events, then the test will timeout.
*/
- while (!(got_create_event && got_destroy_event)) {
- char event[1024];
+ while (!(got_create_event && got_destroy_event) && len < sz - 1) {
ssize_t newlen;
char *create_pos, *destroy_pos;
/* Read 1 less than sizeof(event) to allow space for NULL */
- newlen = read(s, &event[len], sizeof(event) - len - 1);
- ATF_REQUIRE(newlen != -1);
+ newlen = read(s, &event[len], sz - len - 1);
+ ATF_REQUIRE(newlen > 0);
len += newlen;
/* NULL terminate the result */
event[len] = '\0';
- printf("%s", event);
create_pos = strstr(event, create_pat);
if (create_pos != NULL)
@@ -166,7 +173,11 @@
if (destroy_pos != NULL)
got_destroy_event = true;
}
+ printf("%s", event);
+ if (len >= sz - 1)
+ atf_tc_fail("Event buffer overflowed");
+ free(event);
close(s);
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Feb 23, 1:29 PM (1 h, 10 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
16797801
Default Alt Text
D47625.id146802.diff (1 KB)
Attached To
Mode
D47625: devd tests: Fix client_test
Attached
Detach File
Event Timeline
Log In to Comment