bugSynaptic - Bugs: bug #17079, summaries in the...

 
 

bug #17079: summaries in the "Description" column displayed wrong

Submitted by:  Egmont Koblinger <egmont>
Submitted on:  Tue 11 Jul 2006 03:28:13 PM UTC  
 
Category: NoneSeverity: 3 - Normal
Item Group: NoneStatus: None
Privacy: PublicAssigned to: None
Open/Closed: Open

Add a New Comment (Rich MarkupRich Markup):
   

You are not logged in

Please log in, so followups can be emailed to you.

 

Tue 11 Jul 2006 04:21:49 PM UTC, comment #2:

second try... forget my previous patch, use this one :)

Egmont Koblinger <egmont>
Tue 11 Jul 2006 04:00:30 PM UTC, comment #1:

Attached is a proof of concept patch that fixes the summary field. Other fields (long description, maintainer etc...) need similar fix, too.

Egmont Koblinger <egmont>
Tue 11 Jul 2006 03:28:13 PM UTC, original submission:

On the default main window of synaptic, in the Description column (where the short description, i.e. the first line of the corresponding deb field) is displayed, if you move the mouse around over the packages listed here, the end of the summaries are randomly (quite often) redisplayed falsely: a stupid letter appears around the 50th--70th character position, and the string unexpectedly ends there. The same display problem also often occurs in the lower part of the window (where the full description is displayed) if I click on the row of a package.

I attach two screenshots, I did nothing between shooting them except for moving the mouse over the synaptic window.

The reason of the buggy behavior is the following:

In gtk/gtkpkglist.cc:441 the summary() function is called and later the result is displayed. The summary() function is implemented at common/rpackage.cc:123 which in turn calls apt's ShortDesc().

libapt's ShortDesc() returns a correct "string" containing the short description. The summary() function turns this "string" to a "char " using c_str(). The result is valid as long as the "string" is available (since it's actually a pointer to somewhere inside the "string" object.) When this summary() function returns, the string ceases to exist. Hence the returned "char " refers to a memory area that happens to contain the required summary right now, but is not officially allocated, so anyone is allowed to overwrite it at any time. On my particular system (Linux, i586, apt-0.6.44, synaptic-0.57.2, glibc-2.4, gcc-3.4.6 etc.) it occurs very often that the end of the strings get overwritten even before the retval is used in gtkpkglist.cc (before it calls utf8() on the result). Obviously, the behavior can be very different on other systems.

Note that many other functions next to section() (e.g. srcPackage(), maintainer()) suffer from exactly the same problem.

Suggested solution:
These functions should return a "string" instead of "char *". When the return value is being used, it would still be false to write something(summary().c_str()) due to exactly the same reason discussed above, so we need to make sure the string is still available when something() is called. So here's an example of the right usage in gtkpkglist.cc:

case DESCR_COLUMN:
string foo = pkg->summary();
str = utf8(foo.c_str());
g_value_set_string(value, str);

the declaration of "string foo" makes sure that it still exists when its value (as a "char *") is displayed on the screen.

Suggested solution #2:
Use strdup() inside summary() and the caller should free the result.

Egmont Koblinger <egmont>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach File(s):
   
   
Comment:
   

Attached Files
file #10334:  summary-fix-proof-of-concept-try2.patch added by egmont (4kB - text/x-patch - forget the other patch, use this one)
file #10333:  summary-fix-proof-of-concept.patch added by egmont (3kB - text/x-patch - proof of concept - only partial patch!)
file #10332:  syn2.png added by egmont (83kB - image/png - screenshot: bad)
file #10331:  syn1.png added by egmont (82kB - image/png - screenshot: good)

 

Depends on the following items: None found

Items that depend on this one: None found

 

CC list is empty

 

Do you think this task is very important?
If so, you can click here to add your encouragement to it.
This task has 0 encouragements so far.

Only logged-in users can vote.

 

Please enter the title of George Orwell's famous dystopian book (it's a date):

 

 

Follow 4 latest changes.

Date Changed By Updated Field Previous Value => Replaced By
Tue 11 Jul 2006 04:21:49 PM UTCegmontAttached File-=>Added summary-fix-proof-of-concept-try2.patch, #10334
Tue 11 Jul 2006 04:00:30 PM UTCegmontAttached File-=>Added summary-fix-proof-of-concept.patch, #10333
Tue 11 Jul 2006 03:29:34 PM UTCegmontAttached File-=>Added syn2.png, #10332
Tue 11 Jul 2006 03:29:00 PM UTCegmontAttached File-=>Added syn1.png, #10331

Back to the top


Powered by Savane 3.1-cleanup