ad-oliviero / uwufetch

A meme system info tool for Linux, based on nyan/uwu trend on r/linuxmasterrace.
GNU General Public License v3.0
751 stars 49 forks source link

[BUG] buffer overflow due to $SHELL #241

Closed bbjubjub2494 closed 1 year ago

bbjubjub2494 commented 1 year ago

Describe the bug On GNU/Linux, (possibly Mac OS X) supplying a very long string in the $SHELL environment variable results in a crash.

To Reproduce Steps to reproduce the behavior:

# using uwufetch 2.1 from Nixpkgs
SHELL=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa uwufetch
*** buffer overflow detected ***: terminated
fish: Job 1, 'SHELL=aaaaaaaaaaaaaaaaaaaaaaaaa…' terminated by signal SIGABRT (Abandon)

# compiling uwufetch in the repo (no crash but the shell field spills over)
SHELL=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa ./uwufetch
                     guest@harald
  ._.--._.           OWOS     unknown
  \|>_< |/           MOWODEL  HP 470 G7 Notebook PC
   |:_/ |            KEWNEL   Linuwu 6.1.52 x86_64             
  //    \ \   ?      CPUWU    Inteww(R) Cowe(TM) i7-10510U CPUwU @ 1.80GHz
 (|      | ) /       GPUWU    Inteww COwOpowation CometLake-U GT2 UHD Gwaphics
 /'\_   _/`\-        MEMOWY   13296 MiB/15706 MiB
 \___)=(___/         SHEWW    aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaHP 470 G7 Notebook PC
                     PKGS     0: 
                     UWUPTIME 2h, 13m
# can add more a's and get more spillover and eventually a segmentation violation.

Expected behavior No crash, just UwU

Screenshots If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

Additional context Reported here: https://github.com/NixOS/nixpkgs/issues/256531

Are you already working on this bug? I can patch this, please ping me if it slips my mind!