buffer

Why won't int variable come before char array in terms of addressing no matter how I code it in C?

I'm reading Hacking: The Art of Exploitation (2nd Edition), and I'm currently on the section about buffer overflows. In the first example, the variables are declared/initialized in this order: int auth_flag = 0; char password_buffer[16]; The example goes on to explain that you can use gdb to examine auth_flag and password_buffer's ad...

Is it a common practice to re-use the same buffer name for various things in C?

For example, suppose I have a buffer called char journal_name[25] which I use to store the journal name. Now suppose a few lines later in the code I want to store someone's name into a buffer. Should I go char person_name[25] or just reuse the journal_name[25]? The trouble is that everyone who reads the code (and me too after a few week...

polymorphism in c and buffers

I have this union: typedef union Message { message_base base; message_with_parameters parameters; reply_message reply; buffer_t *buffer; // can't figure out what to put here } message; message_with_parameters has a message_base as the first field and reply_message has a message_wit...

C# ==> Asyncsocket reading buffer?

I have a C# server that accepts multiple clients, and multiple messages from each client. 1- In order to start reading from each client i need to pass a buffer (bytes), but the problem is I don't know how much data is the client is going to send. So is there a way to know how much data a client is going to send so that i can start readi...

Potential MySQL Buffer Problem? Need Help Debugging.

Hello, From the middle of a script I've been able to isolate a (very sudden) issue with querying some data from MySQL using PHP. Using the same connection within the same API in the past, I have been able to do numerous (millions of) individual INSERT queries in the past. Also, I've been able to return and manipulate large SELECT resu...

emacs how to invoke the buffer list

Hello! I usually type M-x "buffer-menu", to change buffer. How can I do this with a shorter command? Its quite a long string to type. thanx! ...

Restore previous window position on buffer switch in Emacs

I split windows to view two different parts of the selected buffer simultaneously. If I switch to another buffer in one of the windows and then switch back to the original buffer, I'll lose the previous window position---I'll see the same parts of the selected buffer in both windows. How can I restore window positions amongst buffer swit...

Sensible line buffer size in C?

I'm using popen to read output from shell commands. I will use fgets to read line by line. My question is how to choose the best buffer size for my char* buffer? I remember from a professor telling us to include <limits.h> and use LINE_MAX for such things. It works fine on my Mac, but there's no LINE_MAX on Linux. This mailing list arch...

Is there a way to clear the buffer element by element?

Hi, I've a fread line in my code that reads the contents of the file like this fread(buffer,sizeof(char),1024,file1); I kow that I can free the buffer using free(buffer); but my questions is, is there a way to delete the elements in the buffer one by one?. Say, I used the first element and I no longer need it so I want to delete it...

Buffering data from sockets?

Hi. I am trying to make a simple HTTP server that would be able to parse client requests and send responses back. Now I have a problem. I have to read and handle one line at a time in the request, and I don't know if I should: read one byte at a time, or read chunks of N bytes at a time, put them in a buffer, and then handle the byte...

I must be running into a buffer limit somewhere receiving data from TCP socket using recv( )

Hi, I'm downloading 6kB of data from a test instrument connected via TCP socket. I'm using SOCK_STREAM: if((MySocket=socket(PF_INET,SOCK_STREAM,0))==-1) exit(1); I haven't set the any buffer sizes, so I assume I'm using whatever the default is. I'm having a problem with receiving data. Here's the statement: if((recv(MySocket, &YRa...

How to pause and show video capture using JMF?

Hi. I need to make an applet using JMF that will capture video from the webcam, show it to the user while it's recording and have a pause option to pause ( not stop ) the video capture. I already know how to capture the video and audio and save it to a local file, but, as I said, I need to give the user the option to pause this captur...

Doubt in malloc. C (Linux)

In the following code,what is the meaning of buf = malloc(n * sizeof(char)); is n*sizeof(char) necessary,if yes.. please elaborate. int n; char* buf; fstat(fd, &fs); n = fs.st_size; buf = malloc(n * sizeof(char)); EDIT1 And What if I write (n*sizeof(double)) ...

ob_get_level() starts at level 1

Having a few problems with output buffering. Mainly, I'm trying to run output buffering with the ob_gzhandler callback, but it keeps telling me its using an unsupported compression type. Everything is enabled, and I believe the problem is that running ob_get_level() at the start of my script produces a level of 1. php.ini has my output_b...

How to use SafeBuffer c#

Hi, Can anyone give me a simple example of how to use SafebUffer. i.e how do I create and initialise one - MSDN docs don't appear to show this. ...

How to handle audio-card buffer

Im trying to do a screen-flashing application that flashes the screen depending on the audio(like an audio visualizer, but instead of a visualization like bars or something like that, just flash the screen). I already made the music player and know how to make the widget get full screen and change color(which will flash), but I dont kno...

cin and buffer problem

Hi I have question regarding cin and buffer. I want to make a simple io program which takes integers. Anyway I stumbled to a problem with buffer. Using MinGW in windows7 the following code will print out all four integers that I input. But when I switch to SunOS and compile it with G++ it will only print out the first integer. Is this a...

Circular ShortBuffer for Audio in Java

I'm implementing an audio track class and I'm in need of a good circular buffer implementation. I'm using shorts for my audio samples, so I would prefer to use a ShortBuffer class for the actual buffer. This track will need to be thread-safe but I can guarantee that only one thread will read and another will write on the track. My curren...

How to copy some content in a system clipboard not a kill ring with elisp/emacs?

I learned that copy something to kill buffer, I can use the kill-new buffer (kill-new (file-truename buffer-file-name)) How about copying the content to clipboard? Does emacs/elisp provide the function? ADDED I got 2 answers, but the answer seems to apply X windows system. As I use Aquamacs, it may not be a universal solution that c...

Complete Classic asp page not rendering sometimes for some users (response.buffer?)

I've got a fairly complex classic asp page that for some users doesn't render completely at some times. I wonder if the response.buffer property might have something to do with that. Would setting it to false make it more likely to render completely? I suspect it's crapping out at some point but can't reproduce it on my end. ...