NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

bin/49058: Off by one bug in apropos



>Number:         49058
>Category:       bin
>Synopsis:       Off by one bug in apropos
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    bin-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Aug 01 12:45:00 +0000 2014
>Originator:     Abhinav Upadhyay
>Release:        NetBSD-6
>Organization:
>Environment:
>Description:
I noticed an off by one bug in apropos. The bug is in the html output where 
some garbage characters are seen in the context match output. 

>How-To-Repeat:
apropos -n 1 -h ls
<tr><td colspan=2><b>ls</b>r</td></tr>

(notice the extra 'r' after </b>)

apropos -n 1 -h cp
<tr><td colspan=2><b>cp</b>o</td></tr>

(notice the 'o' after </b>)
>Fix:
Index: apropos-utils.c
===================================================================
RCS file: /cvsroot/src/usr.sbin/makemandb/apropos-utils.c,v
retrieving revision 1.15
diff -u -r1.15 apropos-utils.c
--- apropos-utils.c     2 Apr 2013 17:16:50 -0000       1.15
+++ apropos-utils.c     27 Jul 2014 16:26:26 -0000
@@ -704,9 +704,9 @@
                        break;
                }
        }
-       qsnippet[++i] = 0;
+       qsnippet[i] = 0;
        (*callback)(orig_data->data, section, name, name_desc,
-               (const char *)qsnippet, qsnippet_length);
+               (const char *)qsnippet, strlen(qsnippet));
        free(qsnippet);
        return 0;
 }



Home | Main Index | Thread Index | Old Index