🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: net.bugs.usg
Article #282

Bug in SVR2V2 doprnt.c, FIX

#282
From: Bruce Robertson
Date: Wed, 26 Mar 1986 05:47
57 lines
2425 bytes
Description:
	There is a bug in the doprnt() function for System V, Release 2,
	Version 2.  doprnt() does its own interfacing to the stdio
	data structures, rather than using fwrite() and/or putc().  When
	writing to a FILE stream, it is the responsibility of whoever
	is going to manipulate the data structures to use the _WRTCHK
	macro to insure that an I/O buffer is allocated on the stream.
	doprnt() fails to do this.

Repeat-By:
	Occasionally, redirecting output of a program that does nothing
	but printf()'s to a file will cause the program to core dump.

Fix:
*** /usr/src/lib/libc/port/print/doprnt.c-old	Tue Mar 25 21:26:22 1986
--- /usr/src/lib/libc/port/print/doprnt.c	Tue Mar 25 21:26:25 1986
***************
*** 9,14
  #include <varargs.h>
  #include <values.h>
  #include "print.h"	/* parameters & macros for doprnt */
  
  #define PUT(p, n)     { register unsigned char *newbufptr; \
  			if ((newbufptr = bufptr + n) > bufferend) { \

--- 9,15 -----
  #include <varargs.h>
  #include <values.h>
  #include "print.h"	/* parameters & macros for doprnt */
+ #include "../stdio/stdiom.h"
  
  #define PUT(p, n)     { register unsigned char *newbufptr; \
  			if ((newbufptr = bufptr + n) > bufferend) { \
***************
*** 153,158
  
  	/* initialize buffer pointer and buffer end pointer */
  	{ register int fno = iop->_file;
  	bufptr = iop->_ptr;
  	bufferend = (fno == _NFILE) ? 
  			(unsigned char *)((long) bufptr | (-1L & ~HIBITL))

--- 154,161 -----
  
  	/* initialize buffer pointer and buffer end pointer */
  	{ register int fno = iop->_file;
+ 	if (_WRTCHK(iop))
+ 		return EOF;
  	bufptr = iop->_ptr;
  	bufferend = (fno == _NFILE) ? 
  			(unsigned char *)((long) bufptr | (-1L & ~HIBITL))
-- 

	Bruce Robertson
	UUCP: cbosgd!utah-cs!utah-gr!stride!bruce
	ARPA: stride!bruce@utah-gr.arpa
Technical Details
Message-ID: <563@stride.stride.UUCP>
Path: arc1-ca.pugleaf.net!utzoo!watmath!clyde!burl!ulysses!allegra!mit-eddie!think!harvard!seismo!utah-cs!utah-gr!stride!bruce

Show Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Path: arc1-ca.pugleaf.net!utzoo!watmath!clyde!burl!ulysses!allegra!mit-eddie!think!harvard!seismo!utah-cs!utah-gr!stride!bruce
From: bruce@stride.UUCP (Bruce Robertson)
Newsgroups: net.bugs.usg
Subject: Bug in SVR2V2 doprnt.c, FIX
Message-ID: <563@stride.stride.UUCP>
Date: Wed, 26-Mar-86 00:47:44 EST
Article-I.D.: stride.563
Posted: Wed Mar 26 00:47:44 1986
Date-Received: Sat, 29-Mar-86 01:19:15 EST
Reply-To: bruce@stride.UUCP (Bruce Robertson)
Organization: Stride Micro, Reno, NV.
Lines: 57