Wrox Programmer Forums
|
C++ Programming General discussions for the C++ language. For questions specific to Microsoft's Visual C++ variant, see the Visual C++ forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C++ Programming section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old September 24th, 2003, 03:53 PM
Registered User
 
Join Date: Sep 2003
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default actually it's a C question

I'm trying to find an input function that does not allow buffer overflow. Right now I'm looking at getline but I'm not inputing from a file so I'm also trying to change that. If you know how to do this or any other function that would not allow overflow, please let me know. thanx.

Reply With Quote
  #2 (permalink)  
Old October 1st, 2003, 06:59 PM
Authorized User
 
Join Date: Jul 2003
Posts: 60
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to merediths
Default

Try fgets(chars *s, int n, FILE *stream)... the n is the number of chars to read.

In general, whereis the console I/O functions seem to not take integer arguments specifying buffer length, the file-based equivlants typically do. You can use the file based ones by specifying stdin / stdout.

You may also be intrested in the strn family of functions, which are identical to the str functions ( i.e. strncat instead of strcat) except that they take an integer argument too, which can prevent buffer overflows caused by improperly terminated strings.

Regards
Meredith Shaebanyan

Reply With Quote
  #3 (permalink)  
Old October 13th, 2003, 09:24 AM
Registered User
 
Join Date: Oct 2003
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to midfinger Send a message via MSN to midfinger
Default

Quote:
quote:Originally posted by buzzfever
 I'm trying to find an input function that does not allow buffer overflow. Right now I'm looking at getline but I'm not inputing from a file so I'm also trying to change that. If you know how to do this or any other function that would not allow overflow, please let me know. thanx.

yeah, fgets is a good choice!!!

midFinger
Reply With Quote





Similar Threads
Thread Thread Starter Forum Replies Last Post
question maheshraju ASP.NET 2.0 Basics 3 March 13th, 2008 08:54 AM
Question Ashwini Classic ASP Databases 3 January 10th, 2006 07:20 AM
Question? Calibus Classic ASP Databases 8 August 6th, 2004 08:25 AM
a question gorji C++ Programming 2 August 11th, 2003 07:41 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.