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

View file

@ -105,17 +105,17 @@ int main()
test("foo bar car", 0, 4, 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", 3, 4, true, "", 3, argv_foo_bar_car);
test("foo bar car", 2, 0, false, "too many args", 0, NULL); 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", 0, 3, false, "buffer overflow", 0, NULL);
test("foo bar car", 2, 3, false, "arg too long", 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\"", 3, 0, true, "", 3, argv_foo_bar_car);
test("\"foo\" \"bar\" \"car\"", 0, 4, 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\"", 3, 4, true, "", 3, argv_foo_bar_car);
test("\"foo\" \"bar\" \"car\"", 2, 0, false, "too many args", 0, NULL); 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\"", 0, 3, false, "buffer overflow", 0, NULL);
test("\"foo\" \"bar\" \"car\"", 2, 3, false, "arg too long", 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);
test("\"\\ \"", 0, 0, true, "", 1, argv_space); test("\"\\ \"", 0, 0, true, "", 1, argv_space);
@ -201,15 +201,15 @@ int main()
test("\\\\\\\\\\\\ \\\\\\\\\\\\ \\\\\\\\\\\\", 3, 4, true, "", 3, argv_backslashX3_X3); test("\\\\\\\\\\\\ \\\\\\\\\\\\ \\\\\\\\\\\\", 3, 4, true, "", 3, argv_backslashX3_X3);
test("\\\"\\\"\\\" \\\"\\\"\\\" \\\"\\\"\\\"", 3, 4, true, "", 3, argv_quotmarkX3_X3); test("\\\"\\\"\\\" \\\"\\\"\\\" \\\"\\\"\\\"", 3, 4, true, "", 3, argv_quotmarkX3_X3);
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("\\\\\\\\\\\\ \\\\\\\\\\\\ \\\\\\\\\\\\", 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, "buffer overflow", 0, NULL);
test("\\\\\\\\\\\\ \\\\\\\\\\\\ \\\\\\\\\\\\", 0, 3, false, "arg too long", 0, NULL); test("\\\\\\\\\\\\ \\\\\\\\\\\\ \\\\\\\\\\\\", 0, 3, false, "buffer overflow", 0, NULL);
test("\\\"\\\"\\\" \\\"\\\"\\\" \\\"\\\"\\\"", 0, 3, false, "arg too long", 0, NULL); test("\\\"\\\"\\\" \\\"\\\"\\\" \\\"\\\"\\\"", 0, 3, false, "buffer overflow", 0, NULL);
test("\\ \\ \\ \\ \\ \\ \\ \\ \\ ", 2, 3, false, "arg too long", 0, NULL); test("\\ \\ \\ \\ \\ \\ \\ \\ \\ ", 2, 3, false, "buffer overflow", 0, NULL);
test("\\\\\\\\\\\\ \\\\\\\\\\\\ \\\\\\\\\\\\", 2, 3, false, "arg too long", 0, NULL); test("\\\\\\\\\\\\ \\\\\\\\\\\\ \\\\\\\\\\\\", 2, 3, false, "buffer overflow", 0, NULL);
test("\\\"\\\"\\\" \\\"\\\"\\\" \\\"\\\"\\\"", 2, 3, false, "arg too long", 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);
test(" \\", 0, 0, false, "EOL after backslash", 0, NULL); test(" \\", 0, 0, false, "EOL after backslash", 0, NULL);