11-10-2008
Without seeing input it is hard to guess, but one obvious problem is here:
char line[1024];
while(fgets(line, 1024, fp) != NULL){
This code does not account for the terminating \0
I would chage it to spmething like this:
while(fgets(line, sizeof(buf) - 1, fp) != NULL){
8 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
I have an Oki-Page 14ex with 4MB of RAM. Whenever I print large documents or a several small documents, I get a buffer overflow. Can anyone help? Thanks.
If there is any additional information you need, please feel free to ask.
Tim (3 Replies)
Discussion started by: AltatemTC
3 Replies
2. UNIX for Dummies Questions & Answers
Hi everybody,
I have a problem. I'm trying to ftp a file to a remote system. my shell that wrote is look for a data in a area and when it there its starting the ftp.:) At this point it works. Then it does cd $quelle
ftp -n test <<EUF
user anonymous test
image
put W*
EUF
and so... (12 Replies)
Discussion started by: Peterh
12 Replies
3. Programming
I have the following expression:
#define GB (1024 * 1024 * 1024)
#define TB (1024 * GB)
#define MAX_SIZE (3 * TB)
off_t current_size;
And then the expression...
if (current_size > MAX_SIZE)
{
... (1 Reply)
Discussion started by: tantric
1 Replies
4. HP-UX
Hi,
I get a problem with stack overflow on HP-UX, when running a C program.
Pid 28737 received a SIGSEGV for stack growth failure.
Possible causes: insufficient memory or swap space,
or stack size exceeded maxssiz.
The possible cause i found, was that the definition of a structure had... (0 Replies)
Discussion started by: karthikb23
0 Replies
5. Shell Programming and Scripting
Hi All
I ahve a basic script with a screen. Is there anyway that I can make it possible for the user not to type over the ] ie I would like the inpu to be only with the brakcets?
Any suggestions welcome. :b:
eg
DB name:
function get_fdb {
while ]
do
tput cup 9 41
... (1 Reply)
Discussion started by: WhitesinHolland
1 Replies
6. Ubuntu
I have built kernel 2.6.35 on my Ubuntu system with some specific requirement. I also built some app defined module with the same kernel. I booted up the built version and I find it did not work properly as there is some gui and other modules missing problem. But the system booted up and I did... (0 Replies)
Discussion started by: sunilsukumar4u
0 Replies
7. UNIX for Dummies Questions & Answers
Help!
I have an AIX system that has a power outage.
When I logged in as root and got the system up and running it all looked ok.
But.....when a user tries to log in they receive the error: The perform stack has overflowed OP=2117 PC=2124 E=46 in emmcshflif
icrun is finished
How can I fix... (1 Reply)
Discussion started by: dlegnar
1 Replies
8. UNIX for Advanced & Expert Users
hi folks,
Do you have any idea why this error occurs ?
My server is hp blade in c7000 frames running RHEL 4 update 4.
# uname -a
Linux xxx 3 2.6.9-55.0.12.ELsmp #1 SMP Wed Oct 17 08:15:59 EDT 2007 x86_64 x86_64 x86_64 GNU/Linux
Applications running are jboss or java applications:
#... (4 Replies)
Discussion started by: linuxgeek
4 Replies
GETS(3) Library Functions Manual GETS(3)
NAME
gets, fgets - get a string from a stream
SYNOPSIS
#include <stdio.h>
char *gets(char *s)
char *fgets(char *s, int n, FILE *stream)
DESCRIPTION
Gets reads a string into s from the standard input stream stdin. The string is terminated by a newline character, which is replaced in s
by a null character. Gets returns its argument.
Fgets reads n-1 characters, or up through a newline character, whichever comes first, from the stream into the string s. The last charac-
ter read into s is followed by a null character. Fgets returns its first argument.
SEE ALSO
puts(3), getc(3), scanf(3), fread(3), ferror(3).
DIAGNOSTICS
Gets and fgets return the constant pointer NULL upon end of file or error.
BUGS
Gets deletes a newline, fgets keeps it, all in the name of backward compatibility.
Gets is not present in the Minix-vmd C library for reasons that should be obvious. Use fgets instead.
7th Edition May 15, 1985 GETS(3)