Skip to content

Buffer overflow when compiled with -D_FORTIFY_SOURCE=2 #72

@malcolmlewis

Description

@malcolmlewis

Hi
After building without errors on the openSUSE Build service with the default rpm opt flags, running;

mbpfan -f -v

Results in a buffer overflow error, this is with the 4.1.13 kernel and openSUSE Leap 42.1, it works fine on SLED 11 SP4 (3.0.101 kernel) and seem to have tracked it down to;

diff -Naur a/src/mbpfan.c b/src/mbpfan.c
--- a/src/mbpfan.c 2015-05-05 14:53:12.000000000 -0500
+++ b/src/mbpfan.c 2015-12-21 18:09:22.110045078 -0600
@@ -129,7 +129,7 @@
int counter;
for (counter = 0; counter < 10; counter++) {

  •        char hwmon_path[strlen(path_begin)+1];
    
  •        char hwmon_path[strlen(path_begin)+2];
    
         sprintf(hwmon_path, "%s%d", path_begin, counter);
    

It also works fine if I set -D_FORTIFY_SOURCE=0 (disable), I'm only a packager, not a coder so submit the above as a fix for your consideration.

I also note that the systemd service file using simple doesn't work in openSUSE but forking does.

Hardware: MacBook3,1 (Late 2007) Intel(R) Core(TM)2 Duo CPU T7300 @ 2.00GHz

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions