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

 
 

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

Submitter:  Egmont Koblinger <egmont>
Submitted:  Tue 11 Jul 2006 03:28:13 PM UTC
   
 
Category:  None Severity:  3 - Normal
Item Group:  None Status:  None
Privacy:  Public Assigned to:  None
Open/Closed:  Open
* Mandatory Fields

Add a New Comment Rich Markup
   

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 Files:
   
   
Comment:
   

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

 

Depends on the following items: None found

Items that depend on this one: None found

 

CC list is empty

 

There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

Only logged-in users can vote.

 

Follow 4 latest changes.

Date Changed by Updated Field Previous Value => Replaced by
2006-07-11 egmont Attached File- Added summary-fix-proof-of-concept-try2.patch, #10334
2006-07-11 egmont Attached File- Added summary-fix-proof-of-concept.patch, #10333
2006-07-11 egmont Attached File- Added syn2.png, #10332
2006-07-11 egmont Attached File- Added syn1.png, #10331

Back to the top

Powered by Savane 3.13-f8d8.
Corresponding source code