diff options
| author | Matt Kraai <kraai@debian.org> | 2001-05-18 21:24:58 +0000 |
|---|---|---|
| committer | Matt Kraai <kraai@debian.org> | 2001-05-18 21:24:58 +0000 |
| commit | 1844770fec57bbbdce6d332da90f95cdb71701cf (patch) | |
| tree | 6ec5dc3e96f6d9d6dfe7ef563c17904584739163 /init | |
| parent | d6ef07406d217a728d334ae5e49c4734b4ed26f5 (diff) | |
| download | busybox-w32-1844770fec57bbbdce6d332da90f95cdb71701cf.tar.gz busybox-w32-1844770fec57bbbdce6d332da90f95cdb71701cf.tar.bz2 busybox-w32-1844770fec57bbbdce6d332da90f95cdb71701cf.zip | |
Changed snprintf copies to use strncpy at the suggestion of Aaron Lehmann.
Diffstat (limited to 'init')
| -rw-r--r-- | init/init.c | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/init/init.c b/init/init.c index e7c096d49..c26314c8b 100644 --- a/init/init.c +++ b/init/init.c | |||
| @@ -328,7 +328,7 @@ static void console_init() | |||
| 328 | } | 328 | } |
| 329 | 329 | ||
| 330 | if ((s = getenv("CONSOLE")) != NULL) { | 330 | if ((s = getenv("CONSOLE")) != NULL) { |
| 331 | snprintf(console, sizeof(console) - 1, "%s", s); | 331 | safe_strncpy(console, s, sizeof(console)); |
| 332 | } | 332 | } |
| 333 | #if #cpu(sparc) | 333 | #if #cpu(sparc) |
| 334 | /* sparc kernel supports console=tty[ab] parameter which is also | 334 | /* sparc kernel supports console=tty[ab] parameter which is also |
| @@ -336,9 +336,9 @@ static void console_init() | |||
| 336 | else if ((s = getenv("console")) != NULL) { | 336 | else if ((s = getenv("console")) != NULL) { |
| 337 | /* remap tty[ab] to /dev/ttyS[01] */ | 337 | /* remap tty[ab] to /dev/ttyS[01] */ |
| 338 | if (strcmp(s, "ttya") == 0) | 338 | if (strcmp(s, "ttya") == 0) |
| 339 | snprintf(console, sizeof(console) - 1, "%s", SERIAL_CON0); | 339 | safe_strncpy(console, SERIAL_CON0, sizeof(console)); |
| 340 | else if (strcmp(s, "ttyb") == 0) | 340 | else if (strcmp(s, "ttyb") == 0) |
| 341 | snprintf(console, sizeof(console) - 1, "%s", SERIAL_CON1); | 341 | safe_strncpy(console, SERIAL_CON1, sizeof(console)); |
| 342 | } | 342 | } |
| 343 | #endif | 343 | #endif |
| 344 | else { | 344 | else { |
| @@ -351,7 +351,7 @@ static void console_init() | |||
| 351 | snprintf(console, sizeof(console) - 1, "/dev/tty%d", | 351 | snprintf(console, sizeof(console) - 1, "/dev/tty%d", |
| 352 | vt.v_active); | 352 | vt.v_active); |
| 353 | } else { | 353 | } else { |
| 354 | snprintf(console, sizeof(console) - 1, "%s", _PATH_CONSOLE); | 354 | safe_strncpy(console, _PATH_CONSOLE, sizeof(console)); |
| 355 | tried_devcons++; | 355 | tried_devcons++; |
| 356 | } | 356 | } |
| 357 | } | 357 | } |
| @@ -360,20 +360,20 @@ static void console_init() | |||
| 360 | /* Can't open selected console -- try /dev/console */ | 360 | /* Can't open selected console -- try /dev/console */ |
| 361 | if (!tried_devcons) { | 361 | if (!tried_devcons) { |
| 362 | tried_devcons++; | 362 | tried_devcons++; |
| 363 | snprintf(console, sizeof(console) - 1, "%s", _PATH_CONSOLE); | 363 | safe_strncpy(console, _PATH_CONSOLE, sizeof(console)); |
| 364 | continue; | 364 | continue; |
| 365 | } | 365 | } |
| 366 | /* Can't open selected console -- try vt1 */ | 366 | /* Can't open selected console -- try vt1 */ |
| 367 | if (!tried_vtprimary) { | 367 | if (!tried_vtprimary) { |
| 368 | tried_vtprimary++; | 368 | tried_vtprimary++; |
| 369 | snprintf(console, sizeof(console) - 1, "%s", VT_PRIMARY); | 369 | safe_strncpy(console, VT_PRIMARY, sizeof(console)); |
| 370 | continue; | 370 | continue; |
| 371 | } | 371 | } |
| 372 | break; | 372 | break; |
| 373 | } | 373 | } |
| 374 | if (fd < 0) { | 374 | if (fd < 0) { |
| 375 | /* Perhaps we should panic here? */ | 375 | /* Perhaps we should panic here? */ |
| 376 | snprintf(console, sizeof(console) - 1, "/dev/null"); | 376 | safe_strncpy(console, "/dev/null", sizeof(console)); |
| 377 | } else { | 377 | } else { |
| 378 | /* check for serial console and disable logging to tty5 & running a | 378 | /* check for serial console and disable logging to tty5 & running a |
| 379 | * shell to tty2-4 */ | 379 | * shell to tty2-4 */ |
| @@ -385,7 +385,7 @@ static void console_init() | |||
| 385 | /* Force the TERM setting to vt102 for serial console -- | 385 | /* Force the TERM setting to vt102 for serial console -- |
| 386 | * iff TERM is set to linux (the default) */ | 386 | * iff TERM is set to linux (the default) */ |
| 387 | if (strcmp( termType, "TERM=linux" ) == 0) | 387 | if (strcmp( termType, "TERM=linux" ) == 0) |
| 388 | snprintf(termType, sizeof(termType) - 1, "TERM=vt102"); | 388 | safe_strncpy(termType, "TERM=vt102", sizeof(termType)); |
| 389 | message(LOG | CONSOLE, | 389 | message(LOG | CONSOLE, |
| 390 | "serial console detected. Disabling virtual terminals.\r\n"); | 390 | "serial console detected. Disabling virtual terminals.\r\n"); |
| 391 | } | 391 | } |
