🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.windows.interviews
Article #1357

Bug fix for Font::Width (InterViews 2.6)

#1357
From: Dag Bruck
Date: Thu, 17 Dec 1992 12:18
29 lines
1239 bytes
I don't know if anybody's interested in InterViews 2.6, but maybe it
also applies to later versions.

I have found a bug in Font::Width(const char*, int), where `p' will
access memory outside the allocated array of characters if the string
is not nul-terminated.  I think my fix is ok.

Here is the context diff:

*** /tmp/T0a03374       Thu Dec 17 13:14:05 1992
--- X11-paint.C Thu Dec 17 12:03:24 1992
***************
*** 224,230 ****
      register const char* p, * q;
  
      q = &s[len];
!     for (p = s; *p != '\0' && p < q; p++);
      return XTextWidth((XFontStruct*)rep->info, s, p - s);
  }
  
--- 224,230 ----
      register const char* p, * q;
  
      q = &s[len];
!     for (p = s; p < q && *p != '\0'; p++);
      return XTextWidth((XFontStruct*)rep->info, s, p - s);
  }

Dag Bruck
Technical Details
Message-ID: <1992Dec17.121833.26183@lth.se>
Path: arc1-ca.pugleaf.net!sparky!uunet!mcsun!sunic!news.lth.se!dag

Show Full Headers
Complete Article Headers
Newsgroups: comp.windows.interviews
Path: arc1-ca.pugleaf.net!sparky!uunet!mcsun!sunic!news.lth.se!dag
From: dag@seldon.control.lth.se (Dag Bruck)
Subject: Bug fix for Font::Width (InterViews 2.6)
Message-ID: <1992Dec17.121833.26183@lth.se>
Summary: Contains context diff for fixing the bug.
Sender: news@lth.se
Organization: Department of Automatic Control, Lund, Sweden
Date: Thu, 17 Dec 1992 12:18:33 GMT
Lines: 29