Package: textdraw
Version: 0.2+ds-1
Severity: grave
Tags: patch
Justification: renders package unusable

Dear Maintainer,

when invoking 'td' I got:

*** stack smashing detected ***: terminated

I identified two problems which I fixed and described in
03-avoid-smashed-stack.diff. The other patches are minor changes to fix
some gcc warnings.

Thanks and happy hacking,

   Wolfram


-- System Information:
Debian Release: forky/sid
  APT prefers testing
  APT policy: (500, 'testing')
Architecture: amd64 (x86_64)

Kernel: Linux 6.18.5+deb14-amd64 (SMP w/4 CPU threads; PREEMPT)
Locale: LANG=en_GB.UTF-8, LC_CTYPE=en_GB.UTF-8 (charmap=UTF-8), 
LANGUAGE=en_GB:en
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)

Versions of packages textdraw depends on:
ii  libc6        2.42-11+b1
ii  libncurses6  6.6+20251231-1
ii  libtinfo6    6.6+20251231-1

textdraw recommends no packages.

textdraw suggests no packages.

-- no debconf information
Fix two problems causing smashed stacks. First, out-of-bounds for terminals
lager than 200 chars. Second, improper NULL pointer check.
---
 td.c |    9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

Index: textdraw-0.2+ds/td.c
===================================================================
--- textdraw-0.2+ds.orig/td.c
+++ textdraw-0.2+ds/td.c
@@ -20,7 +20,7 @@ Homepage of Textdraw: http://web.uta4you
 #define ENTER 10       // enter key
 #define DEL 330                // del key
 #define MAXOBJECTS 100 // maximum of possible objects
-#define MAXTXTLEN 200  // max string length
+#define MAXTXTLEN 512  // max string length
 
                                                /* VARIABLES*/
 int x=0, y=0;
@@ -689,7 +690,7 @@ int main(int argc, char *argv[])                    /* MA
        maxrow-=2; maxcol-=1; menrow=maxrow+1;
        init();
 
-       if(argv[1]=='\0')       // new file
+       if(!argv[1])            // new file
        {
        filename="new";
        comment("file 'new' opened - to open existing file: <td filename>");
Generated with a sed-script. Fixes multiple:
warning: zero-length gnu_printf format string [-Wformat-zero-length]
---
 td.c |   18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

Index: textdraw-0.2+ds/td.c
===================================================================
--- textdraw-0.2+ds.orig/td.c
+++ textdraw-0.2+ds/td.c
@@ -80,7 +80,7 @@ void comment_error(char *where)
 void curpos()  //position cursor with printing coordinates
 {      mvprintw(menrow,maxcol-10,"          ");
        mvprintw(menrow,maxcol-10,"x=%d y=%d",x,y);
-       mvprintw(y,x,"");
+       move(y,x);
 }
 
 void cursor()  // move cursor to a new position
@@ -337,7 +337,7 @@ void draw() // draws chart-array on scre
        drawell();
        drawtxt();
 
-       mvprintw(0,0,"");
+       move(0,0);
        for(i=0;i<=maxrow;i++) printw("%s",chart[i]);
        curpos();
        refresh();
@@ -370,7 +370,7 @@ void lineinput()    // inputs line-object-p
 {      lin[lastlin].x1=x; lin[lastlin].y1=y; 
        curpos();
        comment("mark end of line");
-       mvprintw(y,x,"");
+       move(y,x);
 
        cursor();
 
@@ -386,7 +386,7 @@ void recinput()             // inputs rectangle-obj
 {      rec[lastrec].x1=x; rec[lastrec].y1=y;
 
        comment("mark 2nd point of rectangle");
-       mvprintw(y,x,"");
+       move(y,x);
 
        cursor();
 
@@ -401,7 +401,7 @@ void ellinput()             // inputs ellipse-objec
 {      ell[lastell].x1=x; ell[lastell].y1=y;
 
        comment("mark 2nd point of ellipse");
-       mvprintw(y,x,"");
+       move(y,x);
 
        cursor();
 
@@ -436,7 +436,7 @@ void moving()               // moves marked objekt to
 
        markobj();
        if(mark.a=='t')
-       {       mvprintw(txt[mark.nr].x,txt[mark.nr].y,"");
+       {       move(txt[mark.nr].x,txt[mark.nr].y);
                comment("move text to");
                curpos(); cursor(); clearcomment();
                dx=x-txt[mark.nr].x; dy=y-txt[mark.nr].y;
@@ -444,7 +444,7 @@ void moving()               // moves marked objekt to
                txt[mark.nr].y=txt[mark.nr].y+dy;
        }
        if(mark.a=='e')
-       {       mvprintw(ell[mark.nr].x1,ell[mark.nr].y1,"");
+       {       move(ell[mark.nr].x1,ell[mark.nr].y1);
                comment("move ellipse to");
                curpos(); cursor(); clearcomment();
                dx=x-ell[mark.nr].x1; dy=y-ell[mark.nr].y1;
@@ -454,7 +454,7 @@ void moving()               // moves marked objekt to
                ell[mark.nr].y2=ell[mark.nr].y2+dy;
        }
        if(mark.a=='r')
-       {       mvprintw(rec[mark.nr].x1,rec[mark.nr].y1,"");
+       {       move(rec[mark.nr].x1,rec[mark.nr].y1);
                comment("move rectangle to");
                curpos(); cursor(); clearcomment();
                dx=x-rec[mark.nr].x1; dy=y-rec[mark.nr].y1;
@@ -464,7 +464,7 @@ void moving()               // moves marked objekt to
                rec[mark.nr].y2=rec[mark.nr].y2+dy;
        }
        if(mark.a=='l')
-       {       mvprintw(lin[mark.nr].x1,lin[mark.nr].y1,"");
+       {       move(lin[mark.nr].x1,lin[mark.nr].y1);
                comment("move line to");
                curpos(); cursor(); clearcomment();
                dx=x-lin[mark.nr].x1; dy=y-lin[mark.nr].y1;
Fixes:
warning: variable ‘c’ set but not used [-Wunused-but-set-variable]
---
 td.c |    5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

Index: textdraw-0.2+ds/td.c
===================================================================
--- textdraw-0.2+ds.orig/td.c
+++ textdraw-0.2+ds/td.c
@@ -127,7 +127,7 @@ void input()        // reads (inputs) value for
 }
 
 void help()    // print help screen
-{      int c; clear();
+{      clear();
        printw("\nTEXTDRAW 0.2 (c) by Dieter Schoppitsch\n\n");
        printw("c       copy            copy marked object to buffer\n");
        printw("d       delete          delete marked object\n");
@@ -146,7 +146,8 @@ void help() // print help screen
        printw("mark object at 'hot spot'\n");
        printw("to load existing file: <td filename>\n");
        printw("try also: home, end, pgdn, pgup\n");
-       refresh(); c=getch();
+       refresh();
+       getch();
 }
 
                                                /* INIT */
Fixes:
warning: format ‘%d’ expects argument of type ‘int’, but argument 6 has type 
‘size_t’ {aka ‘long unsigned int’}
---
 td.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Index: textdraw-0.2+ds/td.c
===================================================================
--- textdraw-0.2+ds.orig/td.c
+++ textdraw-0.2+ds/td.c
@@ -650,7 +650,7 @@ void save()         // save to file
        }
        fprintf(fil,"%d\n",lasttxt);
        for(i=0;i<lasttxt;i++)
-       {       fprintf(fil,"%d %d %c %d %s\n",
+       {       fprintf(fil,"%d %d %c %zu %s\n",
                txt[i].x,txt[i].y,txt[i].a,strlen(txt[i].t),txt[i].t);
        }
 

Reply via email to