From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from wopr.sciops.net ([216.126.196.60]) by ewsd; Thu May 14 21:37:16 EDT 2020 Received: (qmail 61458 invoked from network); 14 May 2020 18:37:07 -0700 Received: from 100.43.142.88.rev.sfr.net (HELO u16.nope) (qwx@88.142.43.100) by wopr.sciops.net with SMTP; 14 May 2020 18:37:07 -0700 Message-ID: <75EB9E866F3E63B257093D58220AE2F6@wopr.sciops.net> From: qwx Date: Fri, 15 May 2020 03:37:04 +0200 To: 9front@9front.org Subject: Re: [9front] libstdio fscanf regression In-Reply-To: <80954AE3C6C5B7FA9CEE3F96050E744A@eigenstate.org> MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit List-ID: <9front.9front.org> List-Help: X-Glyph: ➈ X-Bullshit: non-blocking callback XMPP over ORM database lifecycle frontend With this patch, fscanf returns the correct value, but the second string isn't correctly nul terminated. games/doom now crashes in crazy ways since it doesn't really do validation of the config file's values. I tweaked your test code: #include #include #include void main(int, char **) { char def[80], strparm[128]; while(scanf("%79s %[^\n]\n", def, strparm) == 2) print("%s %s\n", def, strparm); exits(nil); } Test config file: mouse_sensitivity 6 sfx_volume 2 music_volume 15 show_messages 1 key_right 174 key_left 172 key_up 119 key_down 115 key_strafeleft 97 key_straferight 100 key_fire 157 key_use 32 key_strafe 184 key_speed 182 autorun 1 use_mouse 1 mouseb_fire 0 mouseb_strafe 2 mouseb_forward 1 use_joystick 0 joyb_fire 0 joyb_strafe 1 joyb_use 3 joyb_speed 2 screenblocks 10 detaillevel 0 snd_channels 8 usegamma 1 chatmacro0 "No" chatmacro1 "I'm ready to kick butt!" chatmacro2 "I'm OK." chatmacro3 "I'm not looking too good!" chatmacro4 "Help!" chatmacro5 "You suck!" chatmacro6 "Next time, scumbag..." chatmacro7 "Come here!" chatmacro8 "I'll take care of it." chatmacro9 "Yes" Results: mouse_sensitivity 6 sfx_volume 2 music_volume 15 show_messages 15 key_right 174 key_left 172 key_up 119 key_down 115 key_strafeleft 975 key_straferight 100 key_fire 157 key_use 327 key_strafe 184 key_speed 182 autorun 182 use_mouse 182 mouseb_fire 082 mouseb_strafe 282 mouseb_forward 182 use_joystick 082 joyb_fire 082 joyb_strafe 182 joyb_use 382 joyb_speed 282 screenblocks 102 detaillevel 002 snd_channels 802 usegamma 102 chatmacro0 "No" chatmacro1 "I'm ready to kick butt!" chatmacro2 "I'm OK."y to kick butt!" chatmacro3 "I'm not looking too good!" chatmacro4 "Help!"t looking too good!" chatmacro5 "You suck!"oking too good!" chatmacro6 "Next time, scumbag..."od!" chatmacro7 "Come here!"scumbag..."od!" chatmacro8 "I'll take care of it."od!" chatmacro9 "Yes" take care of it."od!" Oddly, the results are slightly different from within doom's code: [...] usegamma 102 chatmacro0 "No"�5@ chatmacro1 "I'm ready to kick butt!" chatmacro2 "I'm OK."y to kick butt! chatmacro3 "I'm not looking too good!" chatmacro4 "Help!"t looking too good! chatmacro5 "You suck!"oking too good chatmacro6 "Next time, scumbag..."o chatmacro7 "Come here!"scumbag..." chatmacro8 "I'll take care of it." chatmacro9 "Yes" take care of it. Thanks, qwx