GithubHelp home page GithubHelp logo

Comments (4)

andwj avatar andwj commented on August 25, 2024 1

The following patch fixes the silly behavior of storing width values into char pointers, and fixes the segfault here.

diff --git a/src/deutex.c b/src/deutex.c
index c6d85a0f437b..5a356507213b 100644
--- a/src/deutex.c
+++ b/src/deutex.c
@@ -710,6 +710,8 @@ typedef struct {
     comfun_t exec;
     char *use;
     char *help;
+    uint16_t width1;
+    uint16_t width2;
 } comdef_t;
 
 /* FIXME should be at the top of the file but we need comdef_t */
@@ -1124,14 +1126,11 @@ void COMhelp(int argc, const char *argv[])
         /* Do a first pass on all the options for this section. Find out how
            wide the left and right columns need to be. */
         if (d->type == SEC) {
-            uint16_t tmp;
             if (section++)
                 putchar('\n');
             printf("%s:\n", d->help);
-            memcpy(&tmp, d->exec, sizeof(tmp));
-            width1 = tmp + OPTINDENT;
-            memcpy(&tmp, d->use, sizeof(tmp));
-            width2 = tmp;
+            width1 = d->width1 + OPTINDENT;
+            width2 = d->width2;
             if (width1 + 1 + width2 > TTYCOL)
                 width1 = TTYCOL - width2 - COLSPACING;
         }
@@ -1241,17 +1240,17 @@ static void opt_widths(void)
                 if (tmp != width2r)
                     /* Can't happen */
                     tmp = SHRT_MAX;
-                memcpy(current_section->com, &tmp, sizeof(tmp));
+                /* current_section->width2r = tmp; */
 
                 tmp = width1t;
                 if (tmp != width1t)
                     tmp = SHRT_MAX;
-                memcpy(current_section->exec, &tmp, sizeof(tmp));
+                current_section->width1 = tmp;
 
                 tmp = width2t;
                 if (tmp != width2t)
                     tmp = SHRT_MAX;
-                memcpy(current_section->use, &tmp, sizeof(tmp));
+                current_section->width2 = tmp;
             }
         }
 

from deutex.

MartinHowe426 avatar MartinHowe426 commented on August 25, 2024

This also happens on Ubuntu 17.10.1 x64. Using gdb gives the point of failure as:

Program received signal SIGSEGV, Segmentation fault.
opt_widths () at deutex.c:1244
1244	                memcpy(current_section->com, &tmp, sizeof(tmp));

from deutex.

landfillbaby avatar landfillbaby commented on August 25, 2024

also on aarch64. same point of failure. probably architecture independent

from deutex.

chungy avatar chungy commented on August 25, 2024

Thanks. Always wanted to investigate but always put it off :)

from deutex.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.