Page MenuHomeFreeBSD

D11486.diff
No OneTemporary

D11486.diff

Index: head/sbin/init/init.c
===================================================================
--- head/sbin/init/init.c
+++ head/sbin/init/init.c
@@ -1271,8 +1271,8 @@
sp->se_flags |= SE_PRESENT;
- sp->se_device = malloc(sizeof(_PATH_DEV) + strlen(typ->ty_name));
- sprintf(sp->se_device, "%s%s", _PATH_DEV, typ->ty_name);
+ if (asprintf(&sp->se_device, "%s%s", _PATH_DEV, typ->ty_name) < 0)
+ err(1, "asprintf");
/*
* Attempt to open the device, if we get "device not configured"
@@ -1315,8 +1315,8 @@
free(sp->se_getty_argv_space);
free(sp->se_getty_argv);
}
- sp->se_getty = malloc(strlen(typ->ty_getty) + strlen(typ->ty_name) + 2);
- sprintf(sp->se_getty, "%s %s", typ->ty_getty, typ->ty_name);
+ if (asprintf(&sp->se_getty, "%s %s", typ->ty_getty, typ->ty_name) < 0)
+ err(1, "asprintf");
sp->se_getty_argv_space = strdup(sp->se_getty);
sp->se_getty_argv = construct_argv(sp->se_getty_argv_space);
if (sp->se_getty_argv == NULL) {
@@ -1429,7 +1429,7 @@
if (sp->se_type) {
/* Don't use malloc after fork */
strcpy(term, "TERM=");
- strncat(term, sp->se_type, sizeof(term) - 6);
+ strlcat(term, sp->se_type, sizeof(term));
env[0] = term;
env[1] = 0;
}
@@ -1493,7 +1493,7 @@
if (sp->se_type) {
/* Don't use malloc after fork */
strcpy(term, "TERM=");
- strncat(term, sp->se_type, sizeof(term) - 6);
+ strlcat(term, sp->se_type, sizeof(term));
env[0] = term;
env[1] = 0;
} else

File Metadata

Mime Type
text/plain
Expires
Fri, Mar 7, 12:51 AM (12 h, 23 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
17022536
Default Alt Text
D11486.diff (1 KB)

Event Timeline