Project

General

Profile

Actions

Bug #703

closed

hashmake calls gets() but should use fgets().

Added by Garrett D'Amore over 10 years ago. Updated over 8 years ago.

Status:
Resolved
Priority:
Low
Assignee:
-
Category:
cmd - userland programs
Start date:
2011-02-07
Due date:
% Done:

100%

Estimated time:
Difficulty:
Bite-size
Tags:
Gerrit CR:

Description

This can result in an array overrun.

53     hashinit();
54 while (gets(word)) {
55 (void) printf("%.*lo\n", (HASHWIDTH+2)/3, hash(word));
56 }

This is a simple enough thing to fix.

Actions #1

Updated by Roland Mainz over 10 years ago

  • Assignee set to Roland Mainz

Taking bug...

Actions #2

Updated by Garrett D'Amore over 10 years ago

  • Status changed from New to Resolved
  • % Done changed from 0 to 100

Fixed in:

changeset: 13289:0a79ebc0f4b3
tag: tip
user: Roland Mainz <
date: Thu Feb 17 14:49:38 2011 -0800
description:
702 tput calls gets()
703 hashmake calls gets() but should use fgets().
Reviewed by: Dan McDonald <>
Reviewed by: Olga Kryzhanoska <>
Approved by: Garrett D'Amore <>

Actions #3

Updated by Garrett D'Amore over 10 years ago

  • Status changed from Resolved to New
  • % Done changed from 100 to 10

You forgot to consider that fgets() includes \n. (And apparently did not perform enough testing.) This change is now backed out, and the bug is reopened.

Actions #4

Updated by Roland Mainz over 10 years ago

The root problem of the issue was that we tested (both "tput" and
"hashmake") with something like this:
$ diff -u <(/usr/bin/<prog-to-test>) <($ROOT/usr/bin/<prog-to-test>) #
This would've worked perfectly fine if we would've executed this
within a "bldenv" environment... but it looks we ran the tests
outside "bldenv".

This is quite a humilation because a simple $ set -o nounset # in the test chain would've prevented that... I've teaching that students since a decade... and now fell into the same idiot trap. Grrr... (and sorry...) ...

Actions #5

Updated by Garrett D'Amore over 10 years ago

  • Assignee deleted (Roland Mainz)
  • Difficulty set to Bite-size
  • Tags set to needs-triage
Actions #6

Updated by Rich Lowe over 8 years ago

  • Status changed from New to Resolved
  • % Done changed from 10 to 100
  • Tags deleted (needs-triage)

Resolved in 461686c

Actions

Also available in: Atom PDF