🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

1 total messages Started by Steven M. Schultz Thu, 06 Apr 1989 05:14
mkstr truncates strings and converts octal wrong +FIX
#233
Author: Steven M. Schultz
Date: Thu, 06 Apr 1989 05:14
60 lines
1945 bytes
Description:
	'mkstr' incorrectly processes octal numbers in strings.

	Characters of the form \ooo where 'o' is an octal digit
	possibly result in a truncated string (if the first digit
	is 0) AND definitely result in an incorrect value if more
	than one digit is present.

Repeat-By:
	Run 'mkstr' on a file having a string of the form "foo\001bar".
	Note that only "foo\0" makes it to the output.  Guess "0" 
	wasn't considered an octal digit at some point in the past ;-)

	Run 'mkstr' on a file having a string of the form "foo\13", note
	that "foo\203" is the result.  This is a result of shifting by
	7 instead of three in the conversion process.

Fix:
	Apply the following patch to mkstr.c, the extra assign of -1 to ch
	wasn't needed anyway.

*** mkstr.c.old	Wed Apr  5 21:20:30 1989
--- mkstr.c	Wed Apr  5 21:27:03 1989
***************
*** 164,172 ****
  			case 'f':
  				c = '\f';
  				break;
- 			case '0':
- 				c = 0;
- 				break;
  			case '\\':
  				break;
  			default:
--- 164,169 ----
***************
*** 176,186 ****
  				ch = getchar();
  				if (!octdigit(ch))
  					break;
! 				c <<= 7, c += ch - '0';
  				ch = getchar();
  				if (!octdigit(ch))
  					break;
! 				c <<= 3, c+= ch - '0', ch = -1;
  				break;
  			}
  		}
--- 173,183 ----
  				ch = getchar();
  				if (!octdigit(ch))
  					break;
! 				c <<= 3, c += ch - '0';
  				ch = getchar();
  				if (!octdigit(ch))
  					break;
! 				c <<= 3, c += ch - '0';
  				break;
  			}
  		}
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads