I'm trying to create template with "010 editor" and get the following issue.
The array size is not match with length variable.
The array size is not match with length variable
Template:
typedef struct {
int length;
char value[length];
} MyString ;
typedef struct {
int index;
MyString caption;
} MySection;
typedef struct {
int length;
MySection section[length];
} MySections;
struct FILE {
MySections s;
}file;
Binary:
02 00 00 00 01 00 00 00 1D 00 00 00 71 70 73 72
75 74 77 76 79 78 7B 7A 7D 7C 7F 7E 61 60 63 62
65 64 67 66 69 68 6B 6A 6D 02 00 00 00 21 00 00
00 61 60 63 62 65 64 67 66 69 68 6B 6A 6D 6C 6F
6E 71 70 73 72 75 74 77 76 79 78 7B 7A 7D 7C 7F
7E 41
pl. explain where i'm were wrong.
Related
I am using OpenVINO 2020.3.194, with Windows10 x64 and VS2017.I can run the Intel C++ examples, but when I use the inference in my application, I got lots of memory leaks at the exit. Here are some of them:
{2395} normal block at 0x00000260E6A3BCF0, 48 bytes long.
Data: <google.protobuf.> 67 6F 6F 67 6C 65 2E 70 72 6F 74 6F 62 75 66 2E
{2394} normal block at 0x00000260E5958350, 16 bytes long.
Data: < ` > 20 01 A4 E6 60 02 00 00 00 00 00 00 00 00 00 00
{2393} normal block at 0x00000260E6A40100, 88 bytes long.
Data: < ` ` > B0 E4 A2 E6 60 02 00 00 10 E4 A2 E6 60 02 00 00
{2388} normal block at 0x00000260E6A41FB0, 32 bytes long.
Data: <google.protobuf.> 67 6F 6F 67 6C 65 2E 70 72 6F 74 6F 62 75 66 2E
{2387} normal block at 0x00000260E5958170, 16 bytes long.
Data: < ` > 80 00 A4 E6 60 02 00 00 00 00 00 00 00 00 00 00
{2386} normal block at 0x00000260E6A40060, 88 bytes long.
Data: < w ` ` > A0 77 BC E5 60 02 00 00 20 09 A4 E6 60 02 00 00
{2381} normal block at 0x00000260E6A3BC80, 48 bytes long.
Data: <google.protobuf.> 67 6F 6F 67 6C 65 2E 70 72 6F 74 6F 62 75 66 2E
I suspect that happens because I am using Unicode characters set and shared MFC DLL, while the examples compile with MBCS. How I can solve it?
I suggest you try running inference using OpenVINO 2020.4.
Do let us know if this works for you.
How can I convert a hex string to bytes array in Crystal?
Example:
87 A3 69 6E 74 01 A5 66 6C 6F 61 74 CB 3F E0 00 00 00 00 00 00 A7 62 6F 6F 6C 65 61 6E C3 A4 6E 75 6C 6C C0 A6 73 74 72 69 6E 67 A7 66 6F 6F 20 62 61 72 A5 61 72 72 61 79 92 A3 66 6F 6F A3 62 61 72 A6 6F 62 6A 65 63 74 82 A3 66 6F 6F 01 A3 62 61 7A CB 3F E0 00 00 00 00 00 00
Like this:
hexstring = "87 A3 69 6E 74 01 A5 66 6C 6F 61 74 CB 3F E0 00 00 00 00 00 00 A7 62 6F 6F 6C 65 61 6E C3 A4 6E 75 6C 6C C0 A6 73 74 72 69 6E 67 A7 66 6F 6F 20 62 61 72 A5 61 72 72 61 79 92 A3 66 6F 6F A3 62 61 72 A6 6F 62 6A 65 63 74 82 A3 66 6F 6F 01 A3 62 61 7A CB 3F E0 00 00 00 00 00 00"
bytes_array = hexstring.split.map(&.to_u8(16))
pp bytes_array, bytes_array.class
https://play.crystal-lang.org/#/r/19dh
I have to write a small authentication server that, when a client connects, sends a RSA public exponent and modulus to it, and the client returns the username and password encrypted with them. The part where I get the exponent and modulus works fine, the client receives them, and sends the encoded block back; that's not a problem. The problem is in decoding it: the RSA Decryptor always returns 0 as MaxPlaintextLength, and no matter how many different ways I try to move the data around, I can't get it to work.
I'm providing hex dumps of the different parts after the code.
// These are static in the namespace to keep the key loaded.
static CryptoPP::AutoSeededRandomPool rsaRng;
static CryptoPP::InvertibleRSAFunction rsaParameters;
static CryptoPP::RSA::PrivateKey rsaPrivateKey(rsaParameters);
// This is done when the client connects.
{
rsaPrivateKey.GenerateRandomWithKeySize(rsaRng, 1024);
// This is where GetPublicExponent() and GetModulus() are
// encoded and sent to the client. They are sent correctly
// and I receive the encrypted data in a char buffer.
}
// This runs when I receive the encrypted data, which starts
// at &dataBuffer[7] and has a length of rsaPayloadLen.
{
int rsaPlainSize;
byte *rsaBuffer;
rsaBuffer = new byte[rsaPayloadLen];
memcpy(&rsaBuffer[0], &dataBuffer[7], rsaPayloadLen);
CryptoPP::SecByteBlock rsaCypher(rsaBuffer, rsaPayloadLen);
CryptoPP::RSAES_OAEP_SHA_Decryptor rsaDecryptor(rsaPrivateKey);
// At this point I inspected rsaCypher and it does contain the
// expected binary data, and rsaCypher.size() returns 256.
rsaPlainSize = rsaDecryptor.MaxPlaintextLength(rsaCypher.size());
// rsaPlainSize is 0. I have no idea why!
}
Hex dumps of everything at the time of calling MaxPlaintextLength:
rsaPrivateKey.GetPublicExponent():
000000: 11 .
rsaPrivateKey.GetPrivateExponent():
000000: 10 7a fd fd 9e a9 72 8c c3 5d 5b 80 e8 f4 6f bc .z....r..][...o.
000010: bc 6a 7a 51 4f 9f af d3 e4 76 a5 4a 9d fe 17 37 .jzQO....v.J...7
000020: 03 cf 82 24 33 e2 a0 d8 97 26 0a 6b ac 9d b1 de ...$3....&.k....
000030: 39 d5 3a 93 aa 65 66 be 17 43 3c 00 20 77 68 0a 9.:..ef..C<. wh.
000040: ac 2f 77 1e b8 c4 7f 64 52 54 7c 17 54 b6 e6 a4 ./w....dRT|.T...
000050: 95 49 60 7b 7b 16 6a 41 72 54 03 a2 2d 3a 80 8b .I`{{.jArT..-:..
000060: aa 74 fa 77 22 5d 0a d9 81 b2 b2 48 01 db 43 e8 .t.w"].....H..C.
000070: 16 1c c4 c3 a6 bf 45 7e 90 d3 6a 37 10 40 9f 71 ......E~..j7.#.q
rsaPrivateKey.GetModulus():
000000: d2 20 26 61 a6 f0 74 82 ba e6 4e ab 9a 2c 90 a6 . &a..t...N..,..
000010: 62 4d 97 8c b7 34 01 cd a0 e8 bb 77 5e 67 a7 fd bM...4.....w^g..
000020: 70 95 bb 4d 95 89 82 c9 87 25 04 dc d8 da 9b d1 p..M.....%......
000030: 61 5e aa da bc 8c dd f7 a8 99 3d 01 9d f2 6e 89 a^........=...n.
000040: e4 75 ec 91 31 e9 86 f4 da 43 4a ca a4 66 6b 04 .u..1....CJ..fk.
000050: c2 c9 a1 18 1d fa 81 b0 6e ef a5 13 04 44 88 89 ........n....D..
000060: 42 41 be 9c 7c 77 75 96 50 07 70 ad eb 60 e5 05 BA..|wu.P.p..`..
000070: aa a8 d8 27 03 28 cf bb c7 f5 cb 0d b3 b3 96 7f ...'.(..........
rsaPrivateKey.GetPrime1():
000000: d7 9e af ac e4 04 42 e4 58 9c 39 19 0e 56 7c ef ......B.X.9..V|.
000010: b3 bf b6 26 73 25 d8 ab d7 5e d1 e0 56 49 ae 66 ...&s%...^..VI.f
000020: c4 d8 81 bc d0 be c2 ef f4 6a 09 72 ef 72 35 7e .........j.r.r5~
000030: 15 f4 f9 3b f8 be f9 3a a1 0d 3e d0 eb c8 34 11 ...;...:..>...4.
rsaPrivateKey.GetPrime2():
000000: f9 7a 0e 1c 9a 1b eb d1 67 f1 e3 88 1d f3 f1 62 .z......g......b
000010: 9f a2 5c cb 49 76 de 42 25 e1 a4 de ed 50 f3 2d ..\.Iv.B%....P.-
000020: c0 15 c3 70 b5 96 68 51 25 f7 06 24 e4 43 0d b8 ...p..hQ%..$.C..
000030: 7a c5 12 2c 7c 63 20 73 70 61 01 fe b8 b3 71 8f z..,|c spa....q.
Plain text buffer that was encrypted:
000000: 73 74 72 69 6e 67 62 75 66 66 65 72 00 00 00 00 stringbuffer....
000010: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000020: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000030: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000040: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000050: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ..............
rsaCypher:
000000: 0e 9e bd 34 10 16 98 a5 b8 e4 0c 9b 4f 23 71 6d ...4........O#qm
000010: af d6 e8 c1 4d 97 b9 32 cb 25 eb 01 fe 4f 5c 79 ....M..2.%...O\y
000020: 2d d8 32 c4 4f fa e9 2e 58 dd fd 37 7f 08 97 d8 -.2.O...X..7....
000030: 95 bb 6f 04 46 fa 83 77 05 01 43 75 ca be b4 4a ..o.F..w..Cu...J
000040: 60 f9 e7 4a 91 3d bc ac fb e9 41 f3 9d b7 df d3 `..J.=....A.....
000050: a7 03 80 3a 7f 35 98 46 ca 06 b1 f3 d1 7b 56 83 ...:.5.F.....{V.
000060: 1b 00 7d 97 59 39 be 46 d5 cf 6d 2c b3 a7 8e 30 ..}.Y9.F..m,...0
000070: 39 ca ca d5 59 a2 71 43 e7 7e 75 b3 3c d6 a3 a5 9...Y.qC.~u.<...
000080: aa 89 e3 e9 32 e1 a9 c1 a5 a8 f5 66 be 7f c9 ba ....2......f....
000090: 65 35 0f 61 a0 d4 fa c7 ac 8e 28 7c 39 26 3f 01 e5.a......(|9&?.
0000a0: 34 ad 82 69 5e c4 ab 92 48 47 42 04 02 48 79 c4 4..i^...HGB..Hy.
0000b0: 39 6e f2 2c 7c 19 71 34 36 38 1c eb c1 f2 33 f0 9n.,|.q468....3.
0000c0: 49 b9 7e bb c3 16 ed d7 f7 3e 10 a7 cc 2b 8c 31 I.~......>...+.1
0000d0: f1 17 c7 a5 49 ce dd a3 c6 e2 9c 3c 2f 37 e4 97 ....I......</7..
0000e0: ac b7 24 17 b3 f8 75 6f 2a 85 cb 23 7a e1 77 72 ..$...uo*..#z.wr
0000f0: 02 0b 90 28 9b 9b ff 5d 6f 9b 11 11 d3 8b dd 4b ...(...]o......K
rsaCypher.size(): 256
rsaDecryptor.MaxPlaintextLength(rsaCypher.size()): 0
I'm really completely at a loss and the only reason I've spent the whole weekend fighting this is because I'm going to need CryptoPP later for Blowfish and Adler32, otherwise I would have just used another RSA library.
RSAES_OAEP_SHA_Decryptor MaxPlaintextLength returning zero...
Your calculation of rsaPayloadLen is probably not correct. I would suggest you check the size of the ciphertext before you transmit it and after you recover it. I think its size is rsaPayloadLen in you code above.
From the comments in cryptlib.h:
//! maximum length of plaintext for a given ciphertext length
/*! \note This function returns 0 if ciphertextLength is not valid (too long or too short). */
virtual size_t MaxPlaintextLength(size_t ciphertextLength) const =0;
I cannot duplicate when I take plain text, encrypt it, and then pass ciphertext.size() into MaxPlaintextLength. I can duplicate if I pass ciphertext.size() - 1 into MaxPlaintextLength.
As a work around to get you a little further along, you might try using FixedMaxPlaintextLength(). It takes no arguments and only depends upon the public key length. You can use it to find the largest buffer based on the key. But you could fail on decryption.
You should probably show us your encryption code, too. You might not be sizing a buffer correctly.
The whole problem was the key size. The doc said I should use a 1024-bit key, but the other program was expecting a 1152-byte key; apparently that change was never documented. Everything works fine after changing a single line:
rsaPrivateKey.GenerateRandomWithKeySize(rsaRng, 1152);
Leaving this answer here in case someone else ever has this problem. Check the key sizes, and don't trust the documentation!
using FFMPEG API, I try to encode a x264 video to a MP4 file with 0 frame latency and also, in realtime, show the currently encoded frame on screen (with encoding artifacts). The encoding to the file works, but so far I don't get the frames decoded right after writing them to the file. What I try is to feed the packetdata that is returned from avcodec_encode_video() right into avcodec_decode_video2() but the function returns -1 and the cmd output shows:
[h264 # 00000000025F0710] non-existing PPS 0 referenced
[h264 # 00000000025F0710] decode_slice_header error
[h264 # 00000000025F0710] no frame
here is some code i use for encoding:
AVPacket FFMpegEncoder2::write_video_frame(AVFrame* pic, int &numBytes)
{
int out_size, ret;
AVPacket pkt;
/* encode the image */
out_size = avcodec_encode_video(m_cctx, m_outbuf,
m_outbufSize, pic);
/* If size is zero, it means the image was buffered. */
assert(out_size>0) //0 frame delay
av_init_packet(&pkt);
if (m_cctx->coded_frame->pts != AV_NOPTS_VALUE)
pkt.pts = av_rescale_q(m_cctx->coded_frame->pts,m_cctx->time_base, m_video_st->time_base);
if (m_cctx->coded_frame->key_frame)
pkt.flags |= AV_PKT_FLAG_KEY;
pkt.stream_index = m_video_st->index;
pkt.data = m_outbuf;
pkt.size = out_size;
/* Write the compressed frame to the media file. */
ret = av_interleaved_write_frame(m_fctx, &pkt);
if (ret != 0) {
fprintf(stderr, "Error while writing video frame\n");
exit(1);
}
numBytes = out_size;
return pkt;
}
and then I take this returned packet and feed it into the decoder:
const AVFrame* FFMpegDecoder2::decode(AVPacket* packet){
AVPacket pkt;
av_init_packet(&pkt);
pkt.size = packet->size;
pkt.data = packet->data;
int len=0;
int got_picture=0;
while (pkt.size > 0) {
len = avcodec_decode_video2(m_cctx, m_frame, &got_picture, &pkt);
if (len < 0) {
fprintf(stderr, "Error while decoding frame %d\n", m_f);
exit(1);
}
if (got_picture) {
assert(pkt.size==len);
m_f++;
}
pkt.size -= len;
pkt.data += len;
}
assert(got_picture);
return m_frame;
}
but as stated, avcodec_decode_video2() returns -1
what am I doing wrong? Do i need to feed some headerdata into the decoder first somehow?
//edit:
if i set
m_formatCtx->oformat->flags &= ~AVFMT_GLOBALHEADER;
m_codecctx->flags &= ~CODEC_FLAG_GLOBAL_HEADER;
then i can decode the returned packet without error, but the written mp4 file will be black.
//edit: this is how i setup the decoder:
FFMpegDecoder2::FFMpegDecoder2(CodecID id)
: m_codec(NULL)
, m_cctx(NULL)
{
/* Initialize libavcodec, and register all codecs and formats. */
avcodec_register_all();
m_codec = avcodec_find_decoder(id);
if (!m_codec) {
fprintf(stderr, "codec not found\n");
exit(1);
}
m_cctx = avcodec_alloc_context3(m_codec);
m_cctx->codec = m_codec;
m_cctx->pix_fmt = PIX_FMT_YUV420P;
avcodec_open2(m_cctx, m_codec, NULL);
//alloc frame
m_frame = avcodec_alloc_frame();
}
this is what the memory window shows for the first packet (didn't copy all. the size of the first packet is 7859):
0x0000000002E66670 00 00 01 06 05 ff ff 55 dc 45 e9 bd e6 d9 48 b7 96 2c d8 20 d9 23 ee ef 78 32 36 34 20 2d 20 63 6f 72 65 20 31 32 30 20 72 32 31 34 36 20 62 .....ÿÿUÜEé.æÙH·–,Ø Ù#îïx264 - core 120 r2146 b
0x0000000002E6669F 63 64 34 31 64 62 20 2d 20 48 2e 32 36 34 2f 4d 50 45 47 2d 34 20 41 56 43 20 63 6f 64 65 63 20 2d 20 43 6f 70 79 6c 65 66 74 20 32 30 30 33 cd41db - H.264/MPEG-4 AVC codec - Copyleft 2003
0x0000000002E666CE 2d 32 30 31 31 20 2d 20 68 74 74 70 3a 2f 2f 77 77 77 2e 76 69 64 65 6f 6c 61 6e 2e 6f 72 67 2f 78 32 36 34 2e 68 74 6d 6c 20 2d 20 6f 70 74 -2011 - http://www.videolan.org/x264.html - opt
0x0000000002E666FD 69 6f 6e 73 3a 20 63 61 62 61 63 3d 30 20 72 65 66 3d 33 20 64 65 62 6c 6f 63 6b 3d 31 3a 30 3a 30 20 61 6e 61 6c 79 73 65 3d 30 78 33 3a 30 ions: cabac=0 ref=3 deblock=1:0:0 analyse=0x3:0
0x0000000002E6672C 78 31 31 33 20 6d 65 3d 68 65 78 20 73 75 62 6d 65 3d 34 20 70 73 79 3d 31 20 70 73 79 5f 72 64 3d 31 2e 30 30 3a 30 2e 30 30 20 6d 69 78 65 x113 me=hex subme=4 psy=1 psy_rd=1.00:0.00 mixe
0x0000000002E6675B 64 5f 72 65 66 3d 31 20 6d 65 5f 72 61 6e 67 65 3d 31 36 20 63 68 72 6f 6d 61 5f 6d 65 3d 31 20 74 72 65 6c 6c 69 73 3d 30 20 38 78 38 64 63 d_ref=1 me_range=16 chroma_me=1 trellis=0 8x8dc
0x0000000002E6678A 74 3d 31 20 63 71 6d 3d 30 20 64 65 61 64 7a 6f 6e 65 3d 32 31 2c 31 31 20 66 61 73 74 5f 70 73 6b 69 70 3d 31 20 63 68 72 6f 6d 61 5f 71 70 t=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp
0x0000000002E667B9 5f 6f 66 66 73 65 74 3d 30 20 74 68 72 65 61 64 73 3d 31 20 73 6c 69 63 65 64 5f 74 68 72 65 61 64 73 3d 30 20 6e 72 3d 30 20 64 65 63 69 6d _offset=0 threads=1 sliced_threads=0 nr=0 decim
0x0000000002E667E8 61 74 65 3d 31 20 69 6e 74 65 72 6c 61 63 65 64 3d 30 20 62 6c 75 72 61 79 5f 63 6f 6d 70 61 74 3d 30 20 63 6f 6e 73 74 72 61 69 6e 65 64 5f ate=1 interlaced=0 bluray_compat=0 constrained_
0x0000000002E66817 69 6e 74 72 61 3d 30 20 62 66 72 61 6d 65 73 3d 30 20 77 65 69 67 68 74 70 3d 32 20 6b 65 79 69 6e 74 3d 32 35 20 6b 65 79 69 6e 74 5f 6d 69 intra=0 bframes=0 weightp=2 keyint=25 keyint_mi
0x0000000002E66846 6e 3d 32 20 73 63 65 6e 65 63 75 74 3d 34 30 20 69 6e 74 72 61 5f 72 65 66 72 65 73 68 3d 30 20 72 63 3d 61 62 72 20 6d 62 74 72 65 65 3d 30 n=2 scenecut=40 intra_refresh=0 rc=abr mbtree=0
0x0000000002E66875 20 62 69 74 72 61 74 65 3d 34 30 30 20 72 61 74 65 74 6f 6c 3d 31 2e 30 20 71 63 6f 6d 70 3d 30 2e 36 30 20 71 70 6d 69 6e 3d 30 20 71 70 6d bitrate=400 ratetol=1.0 qcomp=0.60 qpmin=0 qpm
0x0000000002E668A4 61 78 3d 36 39 20 71 70 73 74 65 70 3d 34 20 69 70 5f 72 61 74 69 6f 3d 31 2e 34 30 20 61 71 3d 31 3a 31 2e 30 30 00 80 00 00 00 01 65 88 84 ax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00.€....eˆ.
0x0000000002E668D3 11 ef ff f8 22 0f 8a 00 02 09 7e 38 00 08 45 c7 00 01 1d c9 39 3d 87 ff e0 ac 13 03 6d 05 f1 00 10 00 10 12 88 04 00 04 02 60 70 4e 2d cc 38 .ïÿø".Š...~8..EÇ...É9=.ÿà¬..m.ñ.....ˆ....`pN-Ì8
0x0000000002E66902 27 16 e6 07 21 1a e6 1c 84 6b 9f f0 f0 27 15 f2 7b 87 ff c1 58 2a 8a 00 04 b8 80 00 58 00 04 02 62 01 03 c1 c1 04 63 07 04 11 88 90 b1 89 0b '.æ.!.æ..kŸðð'.ò{.ÿÁX*Š..¸€.X...b..ÁÁ.c...ˆ.±..
0x0000000002E66931 1f 2c 11 02 b1 40 00 87 8f a4 f7 0f ff 82 b0 55 06 93 41 c4 10 51 00 00 40 14 00 04 00 a3 b7 35 b7 30 38 26 1e e6 1c 13 0f 73 f2 c1 10 2b 14 .,..±#...¤÷.ÿ.°U.“AÄ.Q..#....£·5·08&.æ...sòÁ.+.
0x0000000002E66960 1f 1f 1c 32 7f 94 11 82 a1 40 01 f1 00 00 40 14 01 22 00 01 e0 1e 22 0a e3 83 1c 19 3d f8 7f e0 b0 16 03 01 22 0f 88 00 02 00 00 16 20 01 17 ...2.”..¡#.ñ..#.."..à.".ãƒ..=ø.à°...".ˆ..... ..
0x0000000002E6698F 03 84 c2 5c 87 09 84 b9 06 4a e4 a4 ae 08 82 d8 e0 00 20 0f 1d 93 df c3 fe 0b 01 54 50 07 88 a8 80 00 64 09 88 58 88 58 83 84 1d 88 38 41 d8 ..Â\.....J䤮..Øà. ..“ßÃþ..TP.ˆ¨€.d.ˆXˆXƒ..ˆ8AØ
0x0000000002E669BE f2 c1 10 2b 14 00 08 f8 e0 00 62 38 64 ff 08 70 13 0a c1 d2 e9 b5 5d ba 10 80 09 a2 01 2e 07 04 c2 dc 87 04 c2 dc 81 c8 66 b9 0e 43 35 cb 0f òÁ.+...øà.b8dÿ.p..ÁÒéµ]º.€.¢....ÂÜ..ÂÜ.Èf..C5Ë.
0x0000000002E669ED ff c1 10 27 2c 00 7e 8e 00 05 64 e4 f6 1f ff 82 28 a0 00 21 99 e3 80 00 99 ac 70 00 11 39 93 93 d8 7f fe 0a c1 40 34 9a 0b e3 40 00 84 40 01 ÿÁ.',.~Ž..däö.ÿ.( .!™ã€.™¬p..9““Ø.þ.Á#4š.ã#..#.
0x0000000002E66A1C 00 01 02 88 fd cd 7d cc 0e 08 a4 dc c3 82 29 37 3f e0 88 14 8b f1 c3 1c 03 27 f0 c3 60 a0 50 62 86 da 36 1f 10 00 0a 80 00 80 14 40 00 20 00 ...ˆýÍ}Ì..¤ÜÃ.)7?àˆ..ñÃ..'ðÃ` Pb.Ú6....€.€.#. .
and this is the encoders output (until after encoding frame 0):
[libx264 # 00000000005ADAA0] using cpu capabilities: MMX2 SSE2Fast SSSE3 FastShu
ffle SSE4.2
[libx264 # 00000000005ADAA0] profile High, level 3.0
[libx264 # 00000000005ADAA0] 264 - core 120 r2146 bcd41db - H.264/MPEG-4 AVC cod
ec - Copyleft 2003-2011 - http://www.videolan.org/x264.html - options: cabac=0 r
ef=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=4 psy=1 psy_rd=1.00:0.00 mixed
_ref=1 me_range=16 chroma_me=1 trellis=0 8x8dct=1 cqm=0 deadzone=21,11 fast_pski
p=1 chroma_qp_offset=0 threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 b
luray_compat=0 constrained_intra=0 bframes=0 weightp=2 keyint=25 keyint_min=2 sc
enecut=40 intra_refresh=0 rc=abr mbtree=0 bitrate=100 ratetol=1.0 qcomp=0.60 qpm
in=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
Output #0, mp4, to 'out2.mp4':
Stream #0:0: Video: h264, yuv420p, 640x480, q=-1--1, 100 kb/s, 90k tbn, 25 t
bc
[mp4 # 0000000000467570] Encoder did not produce proper pts, making some up.
This my packet data:
00 00 00 01 67 64 00 1F AC 56 24 02 80 DA 10 00
00 03 00 10 00 00 03 03 C0 F1 83 18 98 00 00 00
01 68 E8 8E 0B CB 22 C0 00 00 00 01 65 88 82 00
The first a few bytes for a first h264 packet should somewhat look like this.
00 00 00 01 ?7 ... 00 00 00 01 ?8 ... 00 00 00 01 ?5
?7 -> sps
?8 -> pps
?5 -> idr picture
There might be something else like ?6, which is sei, etc. But with SPS, PPS and the idr picture, the decoder should be able to initialize itself properly.
Another case might be the packet contains more than one picture (00 00 00 01 ?5, or 00 00 00 01 ?1). As far as I know, the decoder cannot handle h264 packets with more than one pictures properly.
This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.
Closed 11 years ago.
I've got a program that:
first prints arguments from the command line, with pointers to these arguments, addresses of these pointers and addresses of arguments
then does something similar for the environment variables (however there is a small bug)
after that, all the stack's content is printed starting from buffer "tekst" and going towards the beginning of stack.
At this point, as expected, the program crashes.
The content of the stack is printed as lines:
line number
address in memory
16 consecutive bytes in hexadecimal form
16 consecutive bytes in character form.
Here's a sample output:
ubuntu#ubuntu:~/Desktop$ ./main first_arg second_arg third_arg
argv[0]./main bfd445d1 0xbfd441f4
argv[1]first_arg bfd445d8 0xbfd441f8
argv[2]second_arg bfd445e2 0xbfd441fc
argv[3]third_arg bfd445ed 0xbfd44200
env[0]ORBIT_SOCKETDIR=/tmp/orbit-ubuntu bfd445f7 0xbfd44208
env[1]SSH_AGENT_PID=4294 bfd445f7 0xbfd4420c
env[2]TERM=xterm bfd445f7 0xbfd44210
env[3]SHELL=/bin/bash bfd445f7 0xbfd44214
env[4]XDG_SESSION_COOKIE=b16da184017a223e33dfbc7700000025-1316532826.4763-1998941864 bfd445f7 0xbfd44218
env[5]WINDOWID=60817444 bfd445f7 0xbfd4421c
env[6]GNOME_KEYRING_CONTROL=/tmp/keyring-PF9cWq bfd445f7 0xbfd44220
env[7]GTK_MODULES=canberra-gtk-module bfd445f7 0xbfd44224
env[8]USER=ubuntu bfd445f7 0xbfd44228
env[9]LS_COLORS=rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.dz=01;31:*.gz=01;31:*.lz=01;31:*.xz=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.rar=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.axv=01;35:*.anx=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.axa=00;36:*.oga=00;36:*.spx=00;36:*.xspf=00;36: bfd445f7 0xbfd4422c
env[a]SSH_AUTH_SOCK=/tmp/keyring-PF9cWq/ssh bfd445f7 0xbfd44230
env[b]SESSION_MANAGER=local/ubuntu:#/tmp/.ICE-unix/4253,unix/ubuntu:/tmp/.ICE-unix/4253 bfd445f7 0xbfd44234
env[c]USERNAME=ubuntu bfd445f7 0xbfd44238
env[d]DEFAULTS_PATH=/usr/share/gconf/gnome.default.path bfd445f7 0xbfd4423c
env[e]XDG_CONFIG_DIRS=/etc/xdg/xdg-gnome:/etc/xdg bfd445f7 0xbfd44240
env[f]PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games bfd445f7 0xbfd44244
env[10]DESKTOP_SESSION=gnome bfd445f7 0xbfd44248
env[11]PWD=/home/ubuntu/Desktop bfd445f7 0xbfd4424c
env[12]GDM_KEYBOARD_LAYOUT=us bfd445f7 0xbfd44250
env[13]LANG=en_US.UTF-8 bfd445f7 0xbfd44254
env[14]GDM_LANG=en_US.UTF-8 bfd445f7 0xbfd44258
env[15]MANDATORY_PATH=/usr/share/gconf/gnome.mandatory.path bfd445f7 0xbfd4425c
env[16]UBUNTU_MENUPROXY=libappmenu.so bfd445f7 0xbfd44260
env[17]COMPIZ_CONFIG_PROFILE=ubuntu bfd445f7 0xbfd44264
env[18]GDMSESSION=gnome bfd445f7 0xbfd44268
env[19]SHLVL=1 bfd445f7 0xbfd4426c
env[1a]HOME=/home/ubuntu bfd445f7 0xbfd44270
env[1b]LANGUAGE=en_US:en bfd445f7 0xbfd44274
env[1c]GNOME_DESKTOP_SESSION_ID=this-is-deprecated bfd445f7 0xbfd44278
env[1d]LOGNAME=ubuntu bfd445f7 0xbfd4427c
env[1e]XDG_DATA_DIRS=/usr/share/gnome:/usr/local/share/:/usr/share/ bfd445f7 0xbfd44280
env[1f]DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-DTbn1HNZFU,guid=3b2a0c2f55352a2d70678ffc000000a3 bfd445f7 0xbfd44284
env[20]LESSOPEN=| /usr/bin/lesspipe %s bfd445f7 0xbfd44288
env[21]WINDOWPATH=7 bfd445f7 0xbfd4428c
env[22]DISPLAY=:0.0 bfd445f7 0xbfd44290
env[23]LESSCLOSE=/usr/bin/lesspipe %s %s bfd445f7 0xbfd44294
env[24]RUNNING_UNDER_GDM=yes bfd445f7 0xbfd44298
env[25]COLORTERM=gnome-terminal bfd445f7 0xbfd4429c
env[26]XAUTHORITY=/var/run/gdm/auth-for-ubuntu-Za0Xwx/database bfd445f7 0xbfd442a0
env[27]_=./main bfd445f7 0xbfd442a4
env[28]OLDPWD=/home/ubuntu bfd445f7 0xbfd442a8
001 0xbfd4411e 48 45 52 45 5f 49 53 5f 53 54 41 52 54 00 00 f0 HERE_IS_START???
002 0xbfd4412e fc e2 35 ad 28 00 f4 7f 3b 00 00 00 00 00 00 00 ??5?(???;???????
003 0xbfd4413e 00 00 60 8d 04 08 00 00 00 00 c8 41 d4 bf 37 1e ??`????????A??7?
004 0xbfd4414e 27 00 04 00 00 00 f4 41 d4 bf 08 42 d4 bf 14 44 '??????A???B???D
005 0xbfd4415e 85 00 ff ff ff ff f4 9f b7 00 f4 84 04 08 01 00 ????????????????
006 0xbfd4416e 00 00 b0 41 d4 bf 31 aa b6 00 d0 aa b7 00 30 86 ???A??1???????0?
007 0xbfd4417e 8c b7 01 00 00 00 f4 7f 3b 00 00 00 00 00 00 00 ????????;???????
008 0xbfd4418e 00 00 c8 41 d4 bf c1 93 97 8b be ca 2e 6d 00 00 ???A????????.m??
009 0xbfd4419e 00 00 00 00 00 00 00 00 00 00 04 00 00 00 60 87 ??????????????`?
010 0xbfd441ae 04 08 00 00 00 00 40 0c b7 00 5b 1d 27 00 f4 9f ??????#???[?'???
011 0xbfd441be b7 00 04 00 00 00 60 87 04 08 00 00 00 00 81 87 ??????`?????????
012 0xbfd441ce 04 08 14 88 04 08 04 00 00 00 f4 41 d4 bf 60 8d ???????????A??`?
013 0xbfd441de 04 08 c0 8d 04 08 50 ba b6 00 ec 41 d4 bf 18 a9 ??????P????A????
014 0xbfd441ee b7 00 04 00 00 00 d1 45 d4 bf d8 45 d4 bf e2 45 ???????E???E???E
015 0xbfd441fe d4 bf ed 45 d4 bf 00 00 00 00 f7 45 d4 bf 19 46 ???E???????E???F
016 0xbfd4420e d4 bf 2c 46 d4 bf 37 46 d4 bf 47 46 d4 bf 96 46 ??,F??7F??GF???F
017 0xbfd4421e d4 bf a8 46 d4 bf d2 46 d4 bf f2 46 d4 bf fe 46 ???F???F???F???F
018 0xbfd4422e d4 bf ee 4b d4 bf 14 4c d4 bf 66 4c d4 bf 76 4c ???K???L??fL??vL
019 0xbfd4423e d4 bf a8 4c d4 bf d4 4c d4 bf 21 4d d4 bf 37 4d ???L???L??!M??7M
020 0xbfd4424e d4 bf 50 4d d4 bf 67 4d d4 bf 78 4d d4 bf 8d 4d ??PM??gM??xM???M
021 0xbfd4425e d4 bf c2 4d d4 bf e1 4d d4 bf fe 4d d4 bf 0f 4e ???M???M???M???N
022 0xbfd4426e d4 bf 17 4e d4 bf 29 4e d4 bf 3b 4e d4 bf 67 4e ???N??)N??;N??gN
023 0xbfd4427e d4 bf 76 4e d4 bf b3 4e d4 bf 15 4f d4 bf 35 4f ??vN???N???O??5O
024 0xbfd4428e d4 bf 42 4f d4 bf 4f 4f d4 bf 71 4f d4 bf 87 4f ??BO??OO??qO???O
025 0xbfd4429e d4 bf a0 4f d4 bf d8 4f d4 bf e1 4f d4 bf 00 00 ???O???O???O????
026 0xbfd442ae 00 00 20 00 00 00 14 44 85 00 21 00 00 00 00 40 ?? ????D??!????#
027 0xbfd442be 85 00 10 00 00 00 bf f3 8b 07 06 00 00 00 00 10 ????????????????
028 0xbfd442ce 00 00 11 00 00 00 64 00 00 00 03 00 00 00 34 80 ??????d???????4?
029 0xbfd442de 04 08 04 00 00 00 20 00 00 00 05 00 00 00 09 00 ?????? ?????????
030 0xbfd442ee 00 00 07 00 00 00 00 d0 b5 00 08 00 00 00 00 00 ????????????????
031 0xbfd442fe 00 00 09 00 00 00 60 87 04 08 0b 00 00 00 e7 03 ??????`?????????
032 0xbfd4430e 00 00 0c 00 00 00 e7 03 00 00 0d 00 00 00 e7 03 ????????????????
033 0xbfd4431e 00 00 0e 00 00 00 e7 03 00 00 17 00 00 00 00 00 ????????????????
034 0xbfd4432e 00 00 19 00 00 00 5b 43 d4 bf 1f 00 00 00 f5 4f ??????[C???????O
035 0xbfd4433e d4 bf 0f 00 00 00 6b 43 d4 bf 00 00 00 00 00 00 ??????kC????????
036 0xbfd4434e 00 00 00 00 00 00 00 00 00 00 00 00 00 f0 fc e2 ????????????????
037 0xbfd4435e 43 99 8a 11 5f 85 d2 1d 7b 09 fc 02 c6 69 36 38 C???_???{????i68
038 0xbfd4436e 36 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 6???????????????
039 0xbfd4437e 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ????????????????
040 0xbfd4438e 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ????????????????
041 0xbfd4439e 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ????????????????
042 0xbfd443ae 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ????????????????
043 0xbfd443be 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ????????????????
044 0xbfd443ce 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ????????????????
045 0xbfd443de 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ????????????????
046 0xbfd443ee 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ????????????????
047 0xbfd443fe 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ????????????????
048 0xbfd4440e 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ????????????????
049 0xbfd4441e 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ????????????????
050 0xbfd4442e 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ????????????????
051 0xbfd4443e 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ????????????????
052 0xbfd4444e 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ????????????????
053 0xbfd4445e 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ????????????????
054 0xbfd4446e 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ????????????????
055 0xbfd4447e 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ????????????????
056 0xbfd4448e 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ????????????????
057 0xbfd4449e 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ????????????????
058 0xbfd444ae 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ????????????????
059 0xbfd444be 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ????????????????
060 0xbfd444ce 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ????????????????
061 0xbfd444de 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ????????????????
062 0xbfd444ee 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ????????????????
063 0xbfd444fe 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ????????????????
064 0xbfd4450e 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ????????????????
065 0xbfd4451e 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ????????????????
066 0xbfd4452e 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ????????????????
067 0xbfd4453e 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ????????????????
068 0xbfd4454e 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ????????????????
069 0xbfd4455e 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ????????????????
070 0xbfd4456e 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ????????????????
071 0xbfd4457e 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ????????????????
072 0xbfd4458e 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ????????????????
073 0xbfd4459e 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ????????????????
074 0xbfd445ae 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ????????????????
075 0xbfd445be 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ????????????????
076 0xbfd445ce 00 00 00 2e 2f 6d 61 69 6e 00 66 69 72 73 74 5f ???./main?first_
077 0xbfd445de 61 72 67 00 73 65 63 6f 6e 64 5f 61 72 67 00 74 arg?second_arg?t
078 0xbfd445ee 68 69 72 64 5f 61 72 67 00 4f 52 42 49 54 5f 53 hird_arg?ORBIT_S
079 0xbfd445fe 4f 43 4b 45 54 44 49 52 3d 2f 74 6d 70 2f 6f 72 OCKETDIR=/tmp/or
080 0xbfd4460e 62 69 74 2d 75 62 75 6e 74 75 00 53 53 48 5f 41 bit-ubuntu?SSH_A
081 0xbfd4461e 47 45 4e 54 5f 50 49 44 3d 34 32 39 34 00 54 45 GENT_PID=4294?TE
082 0xbfd4462e 52 4d 3d 78 74 65 72 6d 00 53 48 45 4c 4c 3d 2f RM=xterm?SHELL=/
083 0xbfd4463e 62 69 6e 2f 62 61 73 68 00 58 44 47 5f 53 45 53 bin/bash?XDG_SES
084 0xbfd4464e 53 49 4f 4e 5f 43 4f 4f 4b 49 45 3d 62 31 36 64 SION_COOKIE=b16d
085 0xbfd4465e 61 31 38 34 30 31 37 61 32 32 33 65 33 33 64 66 a184017a223e33df
086 0xbfd4466e 62 63 37 37 30 30 30 30 30 30 32 35 2d 31 33 31 bc7700000025-131
087 0xbfd4467e 36 35 33 32 38 32 36 2e 34 37 36 33 2d 31 39 39 6532826.4763-199
088 0xbfd4468e 38 39 34 31 38 36 34 00 57 49 4e 44 4f 57 49 44 8941864?WINDOWID
089 0xbfd4469e 3d 36 30 38 31 37 34 34 34 00 47 4e 4f 4d 45 5f =60817444?GNOME_
090 0xbfd446ae 4b 45 59 52 49 4e 47 5f 43 4f 4e 54 52 4f 4c 3d KEYRING_CONTROL=
091 0xbfd446be 2f 74 6d 70 2f 6b 65 79 72 69 6e 67 2d 50 46 39 /tmp/keyring-PF9
092 0xbfd446ce 63 57 71 00 47 54 4b 5f 4d 4f 44 55 4c 45 53 3d cWq?GTK_MODULES=
093 0xbfd446de 63 61 6e 62 65 72 72 61 2d 67 74 6b 2d 6d 6f 64 canberra-gtk-mod
094 0xbfd446ee 75 6c 65 00 55 53 45 52 3d 75 62 75 6e 74 75 00 ule?USER=ubuntu?
095 0xbfd446fe 4c 53 5f 43 4f 4c 4f 52 53 3d 72 73 3d 30 3a 64 LS_COLORS=rs=0:d
096 0xbfd4470e 69 3d 30 31 3b 33 34 3a 6c 6e 3d 30 31 3b 33 36 i=01;34:ln=01;36
097 0xbfd4471e 3a 6d 68 3d 30 30 3a 70 69 3d 34 30 3b 33 33 3a :mh=00:pi=40;33:
098 0xbfd4472e 73 6f 3d 30 31 3b 33 35 3a 64 6f 3d 30 31 3b 33 so=01;35:do=01;3
099 0xbfd4473e 35 3a 62 64 3d 34 30 3b 33 33 3b 30 31 3a 63 64 5:bd=40;33;01:cd
100 0xbfd4474e 3d 34 30 3b 33 33 3b 30 31 3a 6f 72 3d 34 30 3b =40;33;01:or=40;
101 0xbfd4475e 33 31 3b 30 31 3a 73 75 3d 33 37 3b 34 31 3a 73 31;01:su=37;41:s
102 0xbfd4476e 67 3d 33 30 3b 34 33 3a 63 61 3d 33 30 3b 34 31 g=30;43:ca=30;41
103 0xbfd4477e 3a 74 77 3d 33 30 3b 34 32 3a 6f 77 3d 33 34 3b :tw=30;42:ow=34;
104 0xbfd4478e 34 32 3a 73 74 3d 33 37 3b 34 34 3a 65 78 3d 30 42:st=37;44:ex=0
105 0xbfd4479e 31 3b 33 32 3a 2a 2e 74 61 72 3d 30 31 3b 33 31 1;32:*.tar=01;31
106 0xbfd447ae 3a 2a 2e 74 67 7a 3d 30 31 3b 33 31 3a 2a 2e 61 :*.tgz=01;31:*.a
107 0xbfd447be 72 6a 3d 30 31 3b 33 31 3a 2a 2e 74 61 7a 3d 30 rj=01;31:*.taz=0
108 0xbfd447ce 31 3b 33 31 3a 2a 2e 6c 7a 68 3d 30 31 3b 33 31 1;31:*.lzh=01;31
109 0xbfd447de 3a 2a 2e 6c 7a 6d 61 3d 30 31 3b 33 31 3a 2a 2e :*.lzma=01;31:*.
110 0xbfd447ee 74 6c 7a 3d 30 31 3b 33 31 3a 2a 2e 74 78 7a 3d tlz=01;31:*.txz=
111 0xbfd447fe 30 31 3b 33 31 3a 2a 2e 7a 69 70 3d 30 31 3b 33 01;31:*.zip=01;3
112 0xbfd4480e 31 3a 2a 2e 7a 3d 30 31 3b 33 31 3a 2a 2e 5a 3d 1:*.z=01;31:*.Z=
113 0xbfd4481e 30 31 3b 33 31 3a 2a 2e 64 7a 3d 30 31 3b 33 31 01;31:*.dz=01;31
114 0xbfd4482e 3a 2a 2e 67 7a 3d 30 31 3b 33 31 3a 2a 2e 6c 7a :*.gz=01;31:*.lz
115 0xbfd4483e 3d 30 31 3b 33 31 3a 2a 2e 78 7a 3d 30 31 3b 33 =01;31:*.xz=01;3
116 0xbfd4484e 31 3a 2a 2e 62 7a 32 3d 30 31 3b 33 31 3a 2a 2e 1:*.bz2=01;31:*.
117 0xbfd4485e 62 7a 3d 30 31 3b 33 31 3a 2a 2e 74 62 7a 3d 30 bz=01;31:*.tbz=0
118 0xbfd4486e 31 3b 33 31 3a 2a 2e 74 62 7a 32 3d 30 31 3b 33 1;31:*.tbz2=01;3
119 0xbfd4487e 31 3a 2a 2e 74 7a 3d 30 31 3b 33 31 3a 2a 2e 64 1:*.tz=01;31:*.d
120 0xbfd4488e 65 62 3d 30 31 3b 33 31 3a 2a 2e 72 70 6d 3d 30 eb=01;31:*.rpm=0
121 0xbfd4489e 31 3b 33 31 3a 2a 2e 6a 61 72 3d 30 31 3b 33 31 1;31:*.jar=01;31
122 0xbfd448ae 3a 2a 2e 72 61 72 3d 30 31 3b 33 31 3a 2a 2e 61 :*.rar=01;31:*.a
123 0xbfd448be 63 65 3d 30 31 3b 33 31 3a 2a 2e 7a 6f 6f 3d 30 ce=01;31:*.zoo=0
124 0xbfd448ce 31 3b 33 31 3a 2a 2e 63 70 69 6f 3d 30 31 3b 33 1;31:*.cpio=01;3
125 0xbfd448de 31 3a 2a 2e 37 7a 3d 30 31 3b 33 31 3a 2a 2e 72 1:*.7z=01;31:*.r
126 0xbfd448ee 7a 3d 30 31 3b 33 31 3a 2a 2e 6a 70 67 3d 30 31 z=01;31:*.jpg=01
127 0xbfd448fe 3b 33 35 3a 2a 2e 6a 70 65 67 3d 30 31 3b 33 35 ;35:*.jpeg=01;35
128 0xbfd4490e 3a 2a 2e 67 69 66 3d 30 31 3b 33 35 3a 2a 2e 62 :*.gif=01;35:*.b
129 0xbfd4491e 6d 70 3d 30 31 3b 33 35 3a 2a 2e 70 62 6d 3d 30 mp=01;35:*.pbm=0
130 0xbfd4492e 31 3b 33 35 3a 2a 2e 70 67 6d 3d 30 31 3b 33 35 1;35:*.pgm=01;35
131 0xbfd4493e 3a 2a 2e 70 70 6d 3d 30 31 3b 33 35 3a 2a 2e 74 :*.ppm=01;35:*.t
132 0xbfd4494e 67 61 3d 30 31 3b 33 35 3a 2a 2e 78 62 6d 3d 30 ga=01;35:*.xbm=0
133 0xbfd4495e 31 3b 33 35 3a 2a 2e 78 70 6d 3d 30 31 3b 33 35 1;35:*.xpm=01;35
134 0xbfd4496e 3a 2a 2e 74 69 66 3d 30 31 3b 33 35 3a 2a 2e 74 :*.tif=01;35:*.t
135 0xbfd4497e 69 66 66 3d 30 31 3b 33 35 3a 2a 2e 70 6e 67 3d iff=01;35:*.png=
136 0xbfd4498e 30 31 3b 33 35 3a 2a 2e 73 76 67 3d 30 31 3b 33 01;35:*.svg=01;3
137 0xbfd4499e 35 3a 2a 2e 73 76 67 7a 3d 30 31 3b 33 35 3a 2a 5:*.svgz=01;35:*
138 0xbfd449ae 2e 6d 6e 67 3d 30 31 3b 33 35 3a 2a 2e 70 63 78 .mng=01;35:*.pcx
139 0xbfd449be 3d 30 31 3b 33 35 3a 2a 2e 6d 6f 76 3d 30 31 3b =01;35:*.mov=01;
140 0xbfd449ce 33 35 3a 2a 2e 6d 70 67 3d 30 31 3b 33 35 3a 2a 35:*.mpg=01;35:*
141 0xbfd449de 2e 6d 70 65 67 3d 30 31 3b 33 35 3a 2a 2e 6d 32 .mpeg=01;35:*.m2
142 0xbfd449ee 76 3d 30 31 3b 33 35 3a 2a 2e 6d 6b 76 3d 30 31 v=01;35:*.mkv=01
143 0xbfd449fe 3b 33 35 3a 2a 2e 6f 67 6d 3d 30 31 3b 33 35 3a ;35:*.ogm=01;35:
144 0xbfd44a0e 2a 2e 6d 70 34 3d 30 31 3b 33 35 3a 2a 2e 6d 34 *.mp4=01;35:*.m4
145 0xbfd44a1e 76 3d 30 31 3b 33 35 3a 2a 2e 6d 70 34 76 3d 30 v=01;35:*.mp4v=0
146 0xbfd44a2e 31 3b 33 35 3a 2a 2e 76 6f 62 3d 30 31 3b 33 35 1;35:*.vob=01;35
147 0xbfd44a3e 3a 2a 2e 71 74 3d 30 31 3b 33 35 3a 2a 2e 6e 75 :*.qt=01;35:*.nu
148 0xbfd44a4e 76 3d 30 31 3b 33 35 3a 2a 2e 77 6d 76 3d 30 31 v=01;35:*.wmv=01
149 0xbfd44a5e 3b 33 35 3a 2a 2e 61 73 66 3d 30 31 3b 33 35 3a ;35:*.asf=01;35:
150 0xbfd44a6e 2a 2e 72 6d 3d 30 31 3b 33 35 3a 2a 2e 72 6d 76 *.rm=01;35:*.rmv
151 0xbfd44a7e 62 3d 30 31 3b 33 35 3a 2a 2e 66 6c 63 3d 30 31 b=01;35:*.flc=01
152 0xbfd44a8e 3b 33 35 3a 2a 2e 61 76 69 3d 30 31 3b 33 35 3a ;35:*.avi=01;35:
153 0xbfd44a9e 2a 2e 66 6c 69 3d 30 31 3b 33 35 3a 2a 2e 66 6c *.fli=01;35:*.fl
154 0xbfd44aae 76 3d 30 31 3b 33 35 3a 2a 2e 67 6c 3d 30 31 3b v=01;35:*.gl=01;
155 0xbfd44abe 33 35 3a 2a 2e 64 6c 3d 30 31 3b 33 35 3a 2a 2e 35:*.dl=01;35:*.
156 0xbfd44ace 78 63 66 3d 30 31 3b 33 35 3a 2a 2e 78 77 64 3d xcf=01;35:*.xwd=
157 0xbfd44ade 30 31 3b 33 35 3a 2a 2e 79 75 76 3d 30 31 3b 33 01;35:*.yuv=01;3
158 0xbfd44aee 35 3a 2a 2e 63 67 6d 3d 30 31 3b 33 35 3a 2a 2e 5:*.cgm=01;35:*.
159 0xbfd44afe 65 6d 66 3d 30 31 3b 33 35 3a 2a 2e 61 78 76 3d emf=01;35:*.axv=
160 0xbfd44b0e 30 31 3b 33 35 3a 2a 2e 61 6e 78 3d 30 31 3b 33 01;35:*.anx=01;3
161 0xbfd44b1e 35 3a 2a 2e 6f 67 76 3d 30 31 3b 33 35 3a 2a 2e 5:*.ogv=01;35:*.
162 0xbfd44b2e 6f 67 78 3d 30 31 3b 33 35 3a 2a 2e 61 61 63 3d ogx=01;35:*.aac=
163 0xbfd44b3e 30 30 3b 33 36 3a 2a 2e 61 75 3d 30 30 3b 33 36 00;36:*.au=00;36
164 0xbfd44b4e 3a 2a 2e 66 6c 61 63 3d 30 30 3b 33 36 3a 2a 2e :*.flac=00;36:*.
165 0xbfd44b5e 6d 69 64 3d 30 30 3b 33 36 3a 2a 2e 6d 69 64 69 mid=00;36:*.midi
166 0xbfd44b6e 3d 30 30 3b 33 36 3a 2a 2e 6d 6b 61 3d 30 30 3b =00;36:*.mka=00;
167 0xbfd44b7e 33 36 3a 2a 2e 6d 70 33 3d 30 30 3b 33 36 3a 2a 36:*.mp3=00;36:*
168 0xbfd44b8e 2e 6d 70 63 3d 30 30 3b 33 36 3a 2a 2e 6f 67 67 .mpc=00;36:*.ogg
169 0xbfd44b9e 3d 30 30 3b 33 36 3a 2a 2e 72 61 3d 30 30 3b 33 =00;36:*.ra=00;3
170 0xbfd44bae 36 3a 2a 2e 77 61 76 3d 30 30 3b 33 36 3a 2a 2e 6:*.wav=00;36:*.
171 0xbfd44bbe 61 78 61 3d 30 30 3b 33 36 3a 2a 2e 6f 67 61 3d axa=00;36:*.oga=
172 0xbfd44bce 30 30 3b 33 36 3a 2a 2e 73 70 78 3d 30 30 3b 33 00;36:*.spx=00;3
173 0xbfd44bde 36 3a 2a 2e 78 73 70 66 3d 30 30 3b 33 36 3a 00 6:*.xspf=00;36:?
174 0xbfd44bee 53 53 48 5f 41 55 54 48 5f 53 4f 43 4b 3d 2f 74 SSH_AUTH_SOCK=/t
175 0xbfd44bfe 6d 70 2f 6b 65 79 72 69 6e 67 2d 50 46 39 63 57 mp/keyring-PF9cW
176 0xbfd44c0e 71 2f 73 73 68 00 53 45 53 53 49 4f 4e 5f 4d 41 q/ssh?SESSION_MA
177 0xbfd44c1e 4e 41 47 45 52 3d 6c 6f 63 61 6c 2f 75 62 75 6e NAGER=local/ubun
178 0xbfd44c2e 74 75 3a 40 2f 74 6d 70 2f 2e 49 43 45 2d 75 6e tu:#/tmp/.ICE-un
179 0xbfd44c3e 69 78 2f 34 32 35 33 2c 75 6e 69 78 2f 75 62 75 ix/4253,unix/ubu
180 0xbfd44c4e 6e 74 75 3a 2f 74 6d 70 2f 2e 49 43 45 2d 75 6e ntu:/tmp/.ICE-un
181 0xbfd44c5e 69 78 2f 34 32 35 33 00 55 53 45 52 4e 41 4d 45 ix/4253?USERNAME
182 0xbfd44c6e 3d 75 62 75 6e 74 75 00 44 45 46 41 55 4c 54 53 =ubuntu?DEFAULTS
183 0xbfd44c7e 5f 50 41 54 48 3d 2f 75 73 72 2f 73 68 61 72 65 _PATH=/usr/share
184 0xbfd44c8e 2f 67 63 6f 6e 66 2f 67 6e 6f 6d 65 2e 64 65 66 /gconf/gnome.def
185 0xbfd44c9e 61 75 6c 74 2e 70 61 74 68 00 58 44 47 5f 43 4f ault.path?XDG_CO
186 0xbfd44cae 4e 46 49 47 5f 44 49 52 53 3d 2f 65 74 63 2f 78 NFIG_DIRS=/etc/x
187 0xbfd44cbe 64 67 2f 78 64 67 2d 67 6e 6f 6d 65 3a 2f 65 74 dg/xdg-gnome:/et
188 0xbfd44cce 63 2f 78 64 67 00 50 41 54 48 3d 2f 75 73 72 2f c/xdg?PATH=/usr/
189 0xbfd44cde 6c 6f 63 61 6c 2f 73 62 69 6e 3a 2f 75 73 72 2f local/sbin:/usr/
190 0xbfd44cee 6c 6f 63 61 6c 2f 62 69 6e 3a 2f 75 73 72 2f 73 local/bin:/usr/s
191 0xbfd44cfe 62 69 6e 3a 2f 75 73 72 2f 62 69 6e 3a 2f 73 62 bin:/usr/bin:/sb
192 0xbfd44d0e 69 6e 3a 2f 62 69 6e 3a 2f 75 73 72 2f 67 61 6d in:/bin:/usr/gam
193 0xbfd44d1e 65 73 00 44 45 53 4b 54 4f 50 5f 53 45 53 53 49 es?DESKTOP_SESSI
194 0xbfd44d2e 4f 4e 3d 67 6e 6f 6d 65 00 50 57 44 3d 2f 68 6f ON=gnome?PWD=/ho
195 0xbfd44d3e 6d 65 2f 75 62 75 6e 74 75 2f 44 65 73 6b 74 6f me/ubuntu/Deskto
196 0xbfd44d4e 70 00 47 44 4d 5f 4b 45 59 42 4f 41 52 44 5f 4c p?GDM_KEYBOARD_L
197 0xbfd44d5e 41 59 4f 55 54 3d 75 73 00 4c 41 4e 47 3d 65 6e AYOUT=us?LANG=en
198 0xbfd44d6e 5f 55 53 2e 55 54 46 2d 38 00 47 44 4d 5f 4c 41 _US.UTF-8?GDM_LA
199 0xbfd44d7e 4e 47 3d 65 6e 5f 55 53 2e 55 54 46 2d 38 00 4d NG=en_US.UTF-8?M
200 0xbfd44d8e 41 4e 44 41 54 4f 52 59 5f 50 41 54 48 3d 2f 75 ANDATORY_PATH=/u
201 0xbfd44d9e 73 72 2f 73 68 61 72 65 2f 67 63 6f 6e 66 2f 67 sr/share/gconf/g
202 0xbfd44dae 6e 6f 6d 65 2e 6d 61 6e 64 61 74 6f 72 79 2e 70 nome.mandatory.p
203 0xbfd44dbe 61 74 68 00 55 42 55 4e 54 55 5f 4d 45 4e 55 50 ath?UBUNTU_MENUP
204 0xbfd44dce 52 4f 58 59 3d 6c 69 62 61 70 70 6d 65 6e 75 2e ROXY=libappmenu.
205 0xbfd44dde 73 6f 00 43 4f 4d 50 49 5a 5f 43 4f 4e 46 49 47 so?COMPIZ_CONFIG
206 0xbfd44dee 5f 50 52 4f 46 49 4c 45 3d 75 62 75 6e 74 75 00 _PROFILE=ubuntu?
207 0xbfd44dfe 47 44 4d 53 45 53 53 49 4f 4e 3d 67 6e 6f 6d 65 GDMSESSION=gnome
208 0xbfd44e0e 00 53 48 4c 56 4c 3d 31 00 48 4f 4d 45 3d 2f 68 ?SHLVL=1?HOME=/h
209 0xbfd44e1e 6f 6d 65 2f 75 62 75 6e 74 75 00 4c 41 4e 47 55 ome/ubuntu?LANGU
210 0xbfd44e2e 41 47 45 3d 65 6e 5f 55 53 3a 65 6e 00 47 4e 4f AGE=en_US:en?GNO
211 0xbfd44e3e 4d 45 5f 44 45 53 4b 54 4f 50 5f 53 45 53 53 49 ME_DESKTOP_SESSI
212 0xbfd44e4e 4f 4e 5f 49 44 3d 74 68 69 73 2d 69 73 2d 64 65 ON_ID=this-is-de
213 0xbfd44e5e 70 72 65 63 61 74 65 64 00 4c 4f 47 4e 41 4d 45 precated?LOGNAME
214 0xbfd44e6e 3d 75 62 75 6e 74 75 00 58 44 47 5f 44 41 54 41 =ubuntu?XDG_DATA
215 0xbfd44e7e 5f 44 49 52 53 3d 2f 75 73 72 2f 73 68 61 72 65 _DIRS=/usr/share
216 0xbfd44e8e 2f 67 6e 6f 6d 65 3a 2f 75 73 72 2f 6c 6f 63 61 /gnome:/usr/loca
217 0xbfd44e9e 6c 2f 73 68 61 72 65 2f 3a 2f 75 73 72 2f 73 68 l/share/:/usr/sh
218 0xbfd44eae 61 72 65 2f 00 44 42 55 53 5f 53 45 53 53 49 4f are/?DBUS_SESSIO
219 0xbfd44ebe 4e 5f 42 55 53 5f 41 44 44 52 45 53 53 3d 75 6e N_BUS_ADDRESS=un
220 0xbfd44ece 69 78 3a 61 62 73 74 72 61 63 74 3d 2f 74 6d 70 ix:abstract=/tmp
221 0xbfd44ede 2f 64 62 75 73 2d 44 54 62 6e 31 48 4e 5a 46 55 /dbus-DTbn1HNZFU
222 0xbfd44eee 2c 67 75 69 64 3d 33 62 32 61 30 63 32 66 35 35 ,guid=3b2a0c2f55
223 0xbfd44efe 33 35 32 61 32 64 37 30 36 37 38 66 66 63 30 30 352a2d70678ffc00
224 0xbfd44f0e 30 30 30 30 61 33 00 4c 45 53 53 4f 50 45 4e 3d 0000a3?LESSOPEN=
225 0xbfd44f1e 7c 20 2f 75 73 72 2f 62 69 6e 2f 6c 65 73 73 70 | /usr/bin/lessp
226 0xbfd44f2e 69 70 65 20 25 73 00 57 49 4e 44 4f 57 50 41 54 ipe %s?WINDOWPAT
227 0xbfd44f3e 48 3d 37 00 44 49 53 50 4c 41 59 3d 3a 30 2e 30 H=7?DISPLAY=:0.0
228 0xbfd44f4e 00 4c 45 53 53 43 4c 4f 53 45 3d 2f 75 73 72 2f ?LESSCLOSE=/usr/
229 0xbfd44f5e 62 69 6e 2f 6c 65 73 73 70 69 70 65 20 25 73 20 bin/lesspipe %s
230 0xbfd44f6e 25 73 00 52 55 4e 4e 49 4e 47 5f 55 4e 44 45 52 %s?RUNNING_UNDER
231 0xbfd44f7e 5f 47 44 4d 3d 79 65 73 00 43 4f 4c 4f 52 54 45 _GDM=yes?COLORTE
232 0xbfd44f8e 52 4d 3d 67 6e 6f 6d 65 2d 74 65 72 6d 69 6e 61 RM=gnome-termina
233 0xbfd44f9e 6c 00 58 41 55 54 48 4f 52 49 54 59 3d 2f 76 61 l?XAUTHORITY=/va
234 0xbfd44fae 72 2f 72 75 6e 2f 67 64 6d 2f 61 75 74 68 2d 66 r/run/gdm/auth-f
235 0xbfd44fbe 6f 72 2d 75 62 75 6e 74 75 2d 5a 61 30 58 77 78 or-ubuntu-Za0Xwx
236 0xbfd44fce 2f 64 61 74 61 62 61 73 65 00 5f 3d 2e 2f 6d 61 /database?_=./ma
237 0xbfd44fde 69 6e 00 4f 4c 44 50 57 44 3d 2f 68 6f 6d 65 2f in?OLDPWD=/home/
238 0xbfd44fee 75 62 75 6e 74 75 00 2e 2f 6d 61 69 6e 00 00 00 ubuntu?./main???
239 0xbfd44ffe 00 00 Segmentation fault (core dumped)
At the moment, I have figured out following things (starting from line 001):
001 buffer tekst
014 argc
014-015 pointers to argv[i]
015 4x null byte
015-025 pointers to env[i]
025-026 4x null byte
038-076 many 0 bytes
076-078 strings of command line arguments
078-238 strings of environments variables
238 name of program
238-239 4x null byte
I have two questions:
What is the other content of stack?
What are used these multiple zeroes between lines 038 and 076 for?
For reference, here's the code I'm using:
#include <iostream>
#include <locale>
#include <unistd.h>
int main(int argc, char* argv[], char* env[]) {
char tekst[] = "HERE_IS_START";
for (int i = 0; i < argc; i++) {
std::cout << "argv[" << i << "]" << argv[i] << " " << std::hex <<
(int) argv[i] << " " << &argv[i] << std::endl;
}
int z = 0;
for (char** env_ = env; *env_ != 0; env_++) {
std::cout << "env[" << z++ << "]" << *env_ << " " << std::hex <<
(int) *env << " " << &(*env_) << std::endl;
}
int row = 16;
char* wsk = tekst;
for (int i = 0;; i++) {
if (i + 1 < 10)std::cout << 0;
if (i + 1 < 100)std::cout << 0;
std::cout << std::dec << (i + 1) << " 0x" << std::hex << (int) wsk << " ";
for (int j = 0; j < row; j++) {
if ((unsigned int) (unsigned char) (wsk[j]) < 16)
std::cout << 0;
std::cout << (unsigned int) (unsigned char) (wsk[j]) <<
" " << std::flush;
}
for (int j = 0; j < row; j++) {
if (isprint((char) (wsk[j])))
std::cout << (char) (wsk[j]);
else
std::cout << '?';
}
std::cout << std::endl;
wsk = wsk + row;
}
return 0;
}
This program was compiled and tested in Ubuntu 11.04.
How do you ever expect to break out of that for loop? You don't give it a repeat condition, and you don't have an explicit break or return anywhere inside the loop. Presumably this segmentation fault is caused by going past the end of the stack into memory you're not allowed to access.
There are two things that will put stuff on the stack before main starts: the operating system itself, and the run-time library and startup code generated by your compiler. You aren't expected to use any of this information directly so it is generally not documented.