buffer

Are C++ strings and streams buffer overflow safe?

跟風遠走 提交于 2019-12-21 09:08:02
问题 If I use std::cin, std::cout and std::string, is there any possibility that someone will exploit the buffer overflow? I ask this because I still see a lot of people that still use null-terminated strings instead of standard containers in C++. 回答1: It depends. Of course, when you use C-style code/API's, there is no difference . But using STL or C++ idioms doesn't guarantee that you're safe. C++ gives you the choice, always. Contrast these two near-identical twins: int n; std::cin >> n; std:

Speeding up the rate that IIS/.NET/LINQ retrieves data from the Network Buffers

六月ゝ 毕业季﹏ 提交于 2019-12-21 07:14:08
问题 When doing a TCP analysis of the traffic between my web servers and database servers I see the network buffers (TCP Window) filling up frequently. The web servers then send TCP messages to the database server telling it that its buffers are full an not to send more data until given an update. For example, this is the size of the network buffer in bytes for one of the more long lived connections to the database server over time: The web servers are running a .NET 4.0 application running in IIS

Node.js How to convert to image from varbinary of MS Sql server datatype

。_饼干妹妹 提交于 2019-12-21 06:57:15
问题 I am accessing third party database where there are images stored in varbinary column. I am writing node.js application to restore varbinary images stored in MS Sql server into .jpg file. When I query varbinary is returned as buffer but from buffer I am not able to restore image into .jpg file. For MS Sql server access i am using https://www.npmjs.com/package/mssql libray. [UPDATE:] : Below are the some of the ways I tried to convert and save as Image. var decodedImage = new Buffer

C| how to check if my input buffer(stdin) is empty?

て烟熏妆下的殇ゞ 提交于 2019-12-21 06:48:30
问题 I want to know how to check if my input buffer(perhaps its called stdin) is empty or not. i dont want the program to stop if the buffer is empty, and i dont want the input to necessarily end with '\n', therefore just using scanf is not enough. i tried searching on google and on this website but no answer was enough. i tried using feof(stdin) like this: int main() { char c,x; int num; scanf("%c",&c); scanf("%c",&x); num=feof(stdin); printf("%d",num); } but all it did was printing 0 no matter

nodejs write 64bit unsigned integer to buffer

懵懂的女人 提交于 2019-12-21 04:09:01
问题 I want to store a 64bit (8 byte) big integer to a nodejs buffer object in big endian format. The problem about this task is that nodejs buffer only supports writing 32bit integers as maximum (with buf.write32UInt32BE(value, offset)). So I thought, why can't we just split the 64bit integer? var buf = new Buffer(8); buf.fill(0) // clear all bytes of the buffer console.log(buf); // outputs <Buffer 00 00 00 00 00 00 00 00> var int = 0xffff; // as dezimal: 65535 buf.write32UInt32BE(0xff, 4); //

Variable-size buffer for receiving UDP packets

橙三吉。 提交于 2019-12-21 02:48:15
问题 I have an UDP socket that will receive some packets, of potentially different sizes, and I handle this asynchronously: socket.async_receive_from(boost::asio::buffer(buffer, 65536), senderEndpoint, handler); The problem here is that to handle the different sizes I have a big buffer, something that could be addressed with variable size buffers. To my understanding, when using async_receive_from , the handler is called with only one packet at a time, because the packet boundaries are preserved

InputStreamReader buffering issue

旧街凉风 提交于 2019-12-20 13:32:25
问题 I am reading data from a file that has, unfortunately, two types of character encoding. There is a header and a body. The header is always in ASCII and defines the character set that the body is encoded in. The header is not fixed length and must be run through a parser to determine its content/length. The file may also be quite large so I need to avoid bring the entire content into memory. So I started off with a single InputStream. I wrap it initially with an InputStreamReader with ASCII

AudioTrack lag: obtainBuffer timed out

一世执手 提交于 2019-12-20 12:35:35
问题 I'm playing WAVs on my Android phone by loading the file and feeding the bytes into AudioTrack.write() via the FileInputStream > BufferedInputStream > DataInputStream method. The audio plays fine and when it is, I can easily adjust sample rate, volume, etc on the fly with nice performance. However, it's taking about two full seconds for a track to start playing. I know AudioTrack has an inescapable delay, but this is ridiculous. Every time I play a track, I get this: 03-13 14:55:57.100: WARN

Byte array with padding of null bytes at the end: how to efficiently copy to smaller byte array

十年热恋 提交于 2019-12-20 11:34:31
问题 Have: [46][111][36][11][101][55][87][30][122][75][66][32][49][55][67][77][88][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0] Want: [46][111][36][11][101][55][87][30][122][75][66][32][49][55][67][77][88] I have an array of bytes size 8192 to start, and starting at some index in that first array until the end of the array the bytes are all null bytes. So there might be 6000 bytes with values and 2196 null bytes at the end in the array. How do I efficiently create a new

resample audio buffer from 44100 to 16000

末鹿安然 提交于 2019-12-20 10:56:24
问题 I have audio data in format of data-uri, then I converted this data-uri into a buffer now I need this buffer data in new samplerate, currently audio data is in 44.1khz and I need data in 16khz, and If I recorded the audio using RecordRTC API and if I record audio in low sample rate then I got distorted audio voice, So I am not getting how to resample my audio buffer, If any of you any idea regarding this then please help me out. Thanks in advance :) 回答1: You can use an OfflineAudioContext to