.
OBS-URL: https://build.opensuse.org/package/show/Base:System/util-linux?expand=0&rev=212
This commit is contained in:
parent
15566fa280
commit
5a45758111
@ -1,28 +1,29 @@
|
||||
--- term-utils/agetty.c
|
||||
+++ term-utils/agetty.c 2014-02-04 08:50:09.798235374 +0000
|
||||
@@ -571,6 +571,7 @@ static void login_options_to_argv(char *
|
||||
+++ term-utils/agetty.c 2014-02-04 09:28:32.564461786 +0000
|
||||
@@ -568,6 +568,8 @@ static void login_options_to_argv(char *
|
||||
*argc = i;
|
||||
}
|
||||
|
||||
+#define is_speed(str) (strlen((str)) == strspn((str), "0123456789,"))
|
||||
+
|
||||
/* Parse command-line arguments. */
|
||||
static void parse_args(int argc, char **argv, struct options *op)
|
||||
{
|
||||
+ char *ptr;
|
||||
int c;
|
||||
|
||||
enum {
|
||||
@@ -745,8 +746,16 @@ static void parse_args(int argc, char **
|
||||
usage(stderr);
|
||||
@@ -746,7 +748,7 @@ static void parse_args(int argc, char **
|
||||
}
|
||||
|
||||
+ c = asprintf(&ptr, "/dev/%s", argv[optind]);
|
||||
+ if (c < 0)
|
||||
+ log_err(_("failed to allocate memory: %m"));
|
||||
+
|
||||
+ c = access(ptr, F_OK);
|
||||
+ free(ptr);
|
||||
+ errno = 0;
|
||||
+
|
||||
/* Accept "tty", "baudrate tty", and "tty baudrate". */
|
||||
- if ('0' <= argv[optind][0] && argv[optind][0] <= '9') {
|
||||
+ if (c < 0) {
|
||||
+ if (is_speed(argv[optind])) {
|
||||
/* Assume BSD style speed. */
|
||||
parse_speeds(op, argv[optind++]);
|
||||
if (argc < optind + 1) {
|
||||
@@ -758,7 +760,7 @@ static void parse_args(int argc, char **
|
||||
op->tty = argv[optind++];
|
||||
if (argc > optind) {
|
||||
char *v = argv[optind++];
|
||||
- if ('0' <= *v && *v <= '9')
|
||||
+ if (is_speed(*v))
|
||||
parse_speeds(op, v);
|
||||
else
|
||||
op->speeds[op->numspeed++] = bcode("9600");
|
||||
|
Loading…
Reference in New Issue
Block a user