mcedit position remember bug

Christian Hamar krics at linuxforum.hu
Mon Mar 21 11:51:37 UTC 2005


> I found maybe a bug (or just a bad configuration) in mcedit postition
> remember option.

I create a small patch for this (just change one line and one little
value). The main problem is in the src/util.c code.

I viewed mc4.6.1pre1 which contains a segfaultable code with atol. That
was fixed in 4.6.1pre4 to use strtoll and check if 

The old code in 4.6.1pre1:

*line = atol(p);
p = strchr (buf, ';');
*column = atol (&p[1]);

The new code in 4.6.1pre4:

*line = strtol(p, const_cast(char **, &p), 10);
if (*p == ';') {
        *column = strtol(p, const_cast(char **, &p), 10);
        if (*p != '\n')
                *column = 0;
        } else
        *line = 1;

We see that there is a check for ; . If found then go and strtol p to
column. But. With this code the column got something like this as
value : (if in filepos : /xx.txt 12;20)

;20 

So the bad ; stays there and column goes to 0 and editor can not set
cursor to ';20' 

The fix is included. Need *column = strtol(p+1, const_cast(char **, &p),
10);

I attached this small patch against 4.6.1pre4

I hope this is good way to fix this problem, if not, please someone
correct out that :)

Regards

Christian Hamar alias krix
Hungary

-------------- next part --------------
A non-text attachment was scrubbed...
Name: mc_filepos_bugfix_461pre4a.patch
Type: text/x-patch
Size: 464 bytes
Desc: not available
URL: <http://lists.midnight-commander.org/pipermail/mc-devel/attachments/20050321/e9035c97/attachment.bin>


More information about the mc-devel mailing list