Bug 80675 - bad source code
bad source code
Status: CLOSED RAWHIDE
Product: Red Hat Linux
Classification: Retired
Component: kakasi (Show other bugs)
8.0
All Linux
medium Severity medium
: ---
: ---
Assigned To: Akira TAGOH
Bill Huang
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2002-12-29 12:41 EST by d.binderman
Modified: 2007-04-18 12:49 EDT (History)
0 users

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2003-04-25 03:11:58 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description d.binderman 2002-12-29 12:41:43 EST
From Bugzilla Helper:
User-Agent: Mozilla/4.6 [en-gb]C-CCK-MCD NetscapeOnline.co.uk  (Win98; I)

Description of problem:

Hello there,

I have just tried to compile kakasi-2.3.4-8 from Redhat 8.0

Here are some of the messages the compiler produces

cc: Info: k2.c, line 157: In this statement, an array is being accessed outside
the bounds specified for the array type. (subscrbounds)
cc: Info: libk2.c, line 157: In this statement, an array is being accessed outside the bounds specified for the array type. (subscrbounds)

Here is an untested patch to shut up the compiler.

./src/k2.c.old ./src/k2.c
*** ./src/k2.c.old	Sun Dec 15 18:14:11 2002
--- ./src/k2.c	Sun Dec 15 18:17:04 2002
***************
*** 140,146 ****
      static struct k2rom_tbl *k2rom_ptr;
      struct k2rom_tbl *p;
      int i, clen, ylen;
!     char buffer[k2rom_buflen];
      unsigned char c1;
      int max_match, match_more;
      char *max_romaji;
--- 140,146 ----
      static struct k2rom_tbl *k2rom_ptr;
      struct k2rom_tbl *p;
      int i, clen, ylen;
!     char buffer[ k2rom_buflen + 1];
      unsigned char c1;
      int max_match, match_more;
      char *max_romaji;
./lib/libk2.c.old ./lib/libk2.c


Version-Release number of selected component (if applicable):


How reproducible:
Always

Steps to Reproduce:
1. compile with any C compiler that sanity checks array indices, such as Compaq.
2.
3.
    

Additional info:
Comment 1 Akira TAGOH 2003-04-24 10:20:20 EDT
I not sure whether it's happened at this point, but right now I don't think
kakasi still has a problem. although 'buffer' is actually allocated for
k2rom_buflen(10) spaces, and basically it allows to use 9 spaces for something
and 1 space for null string. So:

    buffer[k2rom_buflen] = '\0'; clen = k2rom_buflen;
    for (i = 0; i < k2rom_buflen; ++ i) {

these codes are fine. I can't see any codes to be having the problems.
I think that's a compiler bug or excessive warning.
Comment 2 d.binderman 2003-04-24 14:40:00 EDT
I can't believe your answer. 

It is standard C that if an array of size 'n' is declared, then the array 
index 'n' should not be used. Lower limits are inclusive, upper limits
are exclusive.

I strongly recommend reading page 22, section 1.6, of Kernighan & Ritchie
Edition 2, the standard book on the C programming language.


Comment 3 Akira TAGOH 2003-04-25 00:40:57 EDT
You are right. I was confused.
Comment 4 Akira TAGOH 2003-04-25 03:11:58 EDT
fixed in 2.3.4-11

Note You need to log in before you can comment on or make changes to this bug.