Bug 80675

Summary: bad source code
Product: [Retired] Red Hat Linux Reporter: d.binderman
Component: kakasiAssignee: Akira TAGOH <tagoh>
Status: CLOSED RAWHIDE QA Contact: Bill Huang <bhuang>
Severity: medium Docs Contact:
Priority: medium    
Version: 8.0   
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2003-04-25 07:11:58 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description d.binderman 2002-12-29 17:41:43 UTC
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 14:20:20 UTC
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 18:40:00 UTC
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 04:40:57 UTC
You are right. I was confused.

Comment 4 Akira TAGOH 2003-04-25 07:11:58 UTC
fixed in 2.3.4-11