This is an automatic generated email to let you know that the following patch 
were queued at the 
http://git.linuxtv.org/cgit.cgi/v4l-utils.git tree:

Subject: ir-ctl: remove line length limits
Author:  Sean Young <s...@mess.org>
Date:    Mon Dec 4 08:53:10 2023 +0000

By using getline() rather than fgets(), there is no limit on the
line length.

See: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1014887

Signed-off-by: Sean Young <s...@mess.org>

 utils/ir-ctl/ir-ctl.c | 20 ++++++++++++--------
 1 file changed, 12 insertions(+), 8 deletions(-)

---

http://git.linuxtv.org/cgit.cgi/v4l-utils.git/commit/?id=f7e4ee2b571505102328cb3c76bbd44ddb3c9c90
diff --git a/utils/ir-ctl/ir-ctl.c b/utils/ir-ctl/ir-ctl.c
index 3c389bd9e09f..c480a2b1734d 100644
--- a/utils/ir-ctl/ir-ctl.c
+++ b/utils/ir-ctl/ir-ctl.c
@@ -58,8 +58,6 @@
 #define LIRCBUF_SIZE 1024
 #define IR_DEFAULT_TIMEOUT 125000
 #define UNSET UINT32_MAX
-/* Maximum number of columns per line */
-#define LINE_SIZE 8192
 
 const char *argp_program_version = "IR ctl version " V4L_UTILS_VERSION;
 const char *argp_program_bug_address = "Sean Young <s...@mess.org>";
@@ -218,7 +216,8 @@ static struct send *read_file_pulse_space(struct arguments 
*args, const char *fn
 {
        bool expect_pulse = true;
        int lineno = 0, lastspace = 0;
-       char line[LINE_SIZE];
+       char *line = NULL;
+       size_t line_size;
        int len = 0;
        static const char whitespace[] = " \n\r\t";
        struct send *f;
@@ -232,7 +231,7 @@ static struct send *read_file_pulse_space(struct arguments 
*args, const char *fn
        f->carrier = UNSET;
        f->fname = fname;
 
-       while (fgets(line, sizeof(line), input)) {
+       while (getline(&line, &line_size, input) > 0) {
                char *p, *saveptr;
                lineno++;
                char *keyword = strtok_r(line, whitespace, &saveptr);
@@ -364,6 +363,7 @@ static struct send *read_file_pulse_space(struct arguments 
*args, const char *fn
                }
        }
 
+       free(line);
        fclose(input);
 
        if (len == 0) {
@@ -386,7 +386,8 @@ static struct send *read_file_pulse_space(struct arguments 
*args, const char *fn
 static struct send *read_file_raw(struct arguments *args, const char *fname, 
FILE *input)
 {
        int lineno = 0, lastspace = 0;
-       char line[LINE_SIZE];
+       char *line = NULL;
+       size_t line_size;
        int len = 0;
        static const char whitespace[] = " \n\r\t,";
        struct send *f;
@@ -401,7 +402,7 @@ static struct send *read_file_raw(struct arguments *args, 
const char *fname, FIL
        f->carrier = UNSET;
        f->fname = fname;
 
-       while (fgets(line, sizeof(line), input)) {
+       while (getline(&line, &line_size, input) > 0) {
                long int value;
                char *p, *saveptr;
                lineno++;
@@ -457,6 +458,7 @@ static struct send *read_file_raw(struct arguments *args, 
const char *fname, FIL
                }
        }
 
+       free(line);
        fclose(input);
 
        if (len == 0) {
@@ -479,14 +481,15 @@ static struct send *read_file_raw(struct arguments *args, 
const char *fname, FIL
 static struct send *read_file(struct arguments *args, const char *fname)
 {
        FILE *input = fopen(fname, "r");
-       char line[LINE_SIZE];
+       char *line = NULL;
+       size_t line_size;
 
        if (!input) {
                fprintf(stderr, _("%s: could not open: %m\n"), fname);
                return NULL;
        }
 
-       while (fgets(line, sizeof(line), input)) {
+       while (getline(&line, &line_size, input) > 0) {
                int start = 0;
 
                while (isspace(line[start]))
@@ -510,6 +513,7 @@ static struct send *read_file(struct arguments *args, const 
char *fname)
                }
        }
 
+       free(line);
        fclose(input);
 
        fprintf(stderr, _("%s: file is empty\n"), fname);

_______________________________________________
linuxtv-commits mailing list
linuxtv-commits@linuxtv.org
https://www.linuxtv.org/cgi-bin/mailman/listinfo/linuxtv-commits

Reply via email to