Hello,

In hplip-1.7.1 in pcard/fat.c line 350 there is a
wrong ordering in a test which causes invaild array access
and the compiler finds it and shows an "array subscript is above
array bounds" warning which was found by one of our users, see
https://bugzilla.novell.com/show_bug.cgi?id=243047

Here my patch
(too long lines are wrapped here but I think it is still
 possible to understand what I mean).
--------------------------------------------------------------------
--- pcard/fat.c.orig    2006-11-14 00:58:36.000000000 +0100
+++ pcard/fat.c 2007-02-16 11:48:34.000000000 +0100
@@ -347,7 +347,8 @@ int LoadFileInCWD(int filenumber) 
       return FAT_FILE_DELETED;
 
    /* Read file information from directory and convert to 8.3 format. */
-   for (i=0; pde->Name[i] && (pde->Name[i] != ' ') && (i<sizeof(pde->Name));
 i++)  /* copy charactors up to any space */
+   /* Test for i<sizeof(pde->Name) first of all to avoid any access to
 pde->Name[i] when i>=sizeof(pde->Name) */
+   for (i=0; (i<sizeof(pde->Name)) && pde->Name[i] && (pde->Name[i] != ' ');
 i++)  /* copy charactors up to any space */
       fa.Name[i] = pde->Name[i];
    if (pde->Ext[0] && (pde->Ext[0] != ' '))
    {
--------------------------------------------------------------------

Kind Regards
Johannes Meixner
-- 
SUSE LINUX Products GmbH, Maxfeldstrasse 5, 90409 Nuernberg, Germany
AG Nuernberg, HRB 16746, GF: Markus Rex

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
HPLIP-Devel mailing list
HPLIP-Devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/hplip-devel

Reply via email to