1
0
Fork 0
mirror of https://github.com/tailix/libkernaux.git synced 2024-11-13 11:04:27 -05:00

Fix error message

This commit is contained in:
Alex Kotov 2022-01-22 02:50:02 +05:00
parent 7ac36e8fc4
commit 10960c901d
Signed by: kotovalexarian
GPG key ID: 553C0EBBEB5D5F08
2 changed files with 24 additions and 24 deletions

View file

@ -85,7 +85,7 @@ bool kernaux_cmdline(
}
if (buffer_pos >= buffer_size) {
strcpy(error_msg, "arg too long");
strcpy(error_msg, "buffer overflow");
goto fail;
}
@ -127,7 +127,7 @@ bool kernaux_cmdline(
}
if (buffer_pos >= buffer_size) {
strcpy(error_msg, "arg too long");
strcpy(error_msg, "buffer overflow");
goto fail;
}
@ -141,7 +141,7 @@ bool kernaux_cmdline(
case TOKEN:
if (cur == '\0') {
if (buffer_pos >= buffer_size) {
strcpy(error_msg, "arg too long");
strcpy(error_msg, "buffer overflow");
goto fail;
}
@ -151,7 +151,7 @@ bool kernaux_cmdline(
}
else if (cur == ' ') {
if (buffer_pos >= buffer_size) {
strcpy(error_msg, "arg too long");
strcpy(error_msg, "buffer overflow");
goto fail;
}
@ -168,7 +168,7 @@ bool kernaux_cmdline(
}
else {
if (buffer_pos >= buffer_size) {
strcpy(error_msg, "arg too long");
strcpy(error_msg, "buffer overflow");
goto fail;
}
@ -184,7 +184,7 @@ bool kernaux_cmdline(
}
else {
if (buffer_pos >= buffer_size) {
strcpy(error_msg, "arg too long");
strcpy(error_msg, "buffer overflow");
goto fail;
}
@ -204,7 +204,7 @@ bool kernaux_cmdline(
}
else if (cur == '"') {
if (buffer_pos >= buffer_size) {
strcpy(error_msg, "arg too long");
strcpy(error_msg, "buffer overflow");
goto fail;
}
@ -214,7 +214,7 @@ bool kernaux_cmdline(
}
else {
if (buffer_pos >= buffer_size) {
strcpy(error_msg, "arg too long");
strcpy(error_msg, "buffer overflow");
goto fail;
}
@ -230,7 +230,7 @@ bool kernaux_cmdline(
}
else {
if (buffer_pos >= buffer_size) {
strcpy(error_msg, "arg too long");
strcpy(error_msg, "buffer overflow");
goto fail;
}

View file

@ -106,16 +106,16 @@ int main()
test("foo bar car", 3, 4, true, "", 3, argv_foo_bar_car);
test("foo bar car", 2, 0, false, "too many args", 0, NULL);
test("foo bar car", 0, 3, false, "arg too long", 0, NULL);
test("foo bar car", 2, 3, false, "arg too long", 0, NULL);
test("foo bar car", 0, 3, false, "buffer overflow", 0, NULL);
test("foo bar car", 2, 3, false, "buffer overflow", 0, NULL);
test("\"foo\" \"bar\" \"car\"", 3, 0, true, "", 3, argv_foo_bar_car);
test("\"foo\" \"bar\" \"car\"", 0, 4, true, "", 3, argv_foo_bar_car);
test("\"foo\" \"bar\" \"car\"", 3, 4, true, "", 3, argv_foo_bar_car);
test("\"foo\" \"bar\" \"car\"", 2, 0, false, "too many args", 0, NULL);
test("\"foo\" \"bar\" \"car\"", 0, 3, false, "arg too long", 0, NULL);
test("\"foo\" \"bar\" \"car\"", 2, 3, false, "arg too long", 0, NULL);
test("\"foo\" \"bar\" \"car\"", 0, 3, false, "buffer overflow", 0, NULL);
test("\"foo\" \"bar\" \"car\"", 2, 3, false, "buffer overflow", 0, NULL);
test("\\ ", 0, 0, true, "", 1, argv_space);
test("\"\\ \"", 0, 0, true, "", 1, argv_space);
@ -204,12 +204,12 @@ int main()
test("\\ \\ \\ \\ \\ \\ \\ \\ \\ ", 2, 0, false, "too many args", 0, NULL);
test("\\\\\\\\\\\\ \\\\\\\\\\\\ \\\\\\\\\\\\", 2, 0, false, "too many args", 0, NULL);
test("\\\"\\\"\\\" \\\"\\\"\\\" \\\"\\\"\\\"", 2, 0, false, "too many args", 0, NULL);
test("\\ \\ \\ \\ \\ \\ \\ \\ \\ ", 0, 3, false, "arg too long", 0, NULL);
test("\\\\\\\\\\\\ \\\\\\\\\\\\ \\\\\\\\\\\\", 0, 3, false, "arg too long", 0, NULL);
test("\\\"\\\"\\\" \\\"\\\"\\\" \\\"\\\"\\\"", 0, 3, false, "arg too long", 0, NULL);
test("\\ \\ \\ \\ \\ \\ \\ \\ \\ ", 2, 3, false, "arg too long", 0, NULL);
test("\\\\\\\\\\\\ \\\\\\\\\\\\ \\\\\\\\\\\\", 2, 3, false, "arg too long", 0, NULL);
test("\\\"\\\"\\\" \\\"\\\"\\\" \\\"\\\"\\\"", 2, 3, false, "arg too long", 0, NULL);
test("\\ \\ \\ \\ \\ \\ \\ \\ \\ ", 0, 3, false, "buffer overflow", 0, NULL);
test("\\\\\\\\\\\\ \\\\\\\\\\\\ \\\\\\\\\\\\", 0, 3, false, "buffer overflow", 0, NULL);
test("\\\"\\\"\\\" \\\"\\\"\\\" \\\"\\\"\\\"", 0, 3, false, "buffer overflow", 0, NULL);
test("\\ \\ \\ \\ \\ \\ \\ \\ \\ ", 2, 3, false, "buffer overflow", 0, NULL);
test("\\\\\\\\\\\\ \\\\\\\\\\\\ \\\\\\\\\\\\", 2, 3, false, "buffer overflow", 0, NULL);
test("\\\"\\\"\\\" \\\"\\\"\\\" \\\"\\\"\\\"", 2, 3, false, "buffer overflow", 0, NULL);
test("\\", 0, 0, false, "EOL after backslash", 0, NULL);
test(" \\", 0, 0, false, "EOL after backslash", 0, NULL);