commit-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Commit-gnuradio] [gnuradio] 11/29: zeromq: fix segfault in tag_headers


From: git
Subject: [Commit-gnuradio] [gnuradio] 11/29: zeromq: fix segfault in tag_headers
Date: Tue, 13 Jan 2015 01:04:27 +0000 (UTC)

This is an automated email from the git hooks/post-receive script.

jcorgan pushed a commit to branch master
in repository gnuradio.

commit c1f42c12af1b4deedf7d72c477b40d4cc369ee41
Author: Johnathan Corgan <address@hidden>
Date:   Fri Oct 31 16:01:19 2014 -0700

    zeromq: fix segfault in tag_headers
---
 gr-zeromq/lib/tag_headers.cc | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/gr-zeromq/lib/tag_headers.cc b/gr-zeromq/lib/tag_headers.cc
index b45025d..42a65be 100644
--- a/gr-zeromq/lib/tag_headers.cc
+++ b/gr-zeromq/lib/tag_headers.cc
@@ -33,10 +33,12 @@ namespace gr {
 
       std::stringstream ss;
       size_t ntags = tags.size();
-      ss.write( reinterpret_cast< const char* >( offset ), sizeof(uint64_t) ); 
 // offset
+      ss.write( reinterpret_cast< const char* >( &offset ), sizeof(uint64_t) 
);  // offset
       ss.write( reinterpret_cast< const char* >( &ntags ), sizeof(size_t) );   
   // num tags
       std::stringbuf sb("");
+      std::cout << "TX TAGS: (offset="<<offset<<" ntags="<<ntags<<")\n";
       for(size_t i=0; i<tags.size(); i++){
+        std::cout << "TX TAG: (" << tags[i].offset << ", " << tags[i].key << 
", " << tags[i].value << ", " << tags[i].srcid << ")\n";
         ss.write( reinterpret_cast< const char* >( &tags[i].offset ), 
sizeof(uint64_t) );   // offset
         sb.str("");
         pmt::serialize( tags[i].key, sb );                                     
      // key
@@ -51,17 +53,28 @@ namespace gr {
     std::string
     parse_tag_header(std::string &buf_in, uint64_t &offset_out, 
std::vector<gr::tag_t> tags_out) {
 
+      std::cout << "sblen: " << buf_in.size() <<"\n";
       std::istringstream iss( buf_in );
       size_t   rcv_ntags;
       iss.read( (char*)&offset_out, sizeof(uint64_t ) );
       iss.read( (char*)&rcv_ntags,  sizeof(size_t   ) );
+      std::cout << "RX TAGS: (offset="<<offset_out<<" 
ntags="<<rcv_ntags<<")\n";
+      int rd_offset = sizeof(uint64_t) + sizeof(size_t);
       for(size_t i=0; i<rcv_ntags; i++){
         gr::tag_t newtag;       
         iss.read( (char*)&newtag.offset, sizeof(uint64_t ) );
-        std::stringbuf sb( iss.str() );
+        rd_offset += sizeof(uint64_t);
+
+        std::stringbuf sb( iss.str().substr(rd_offset) );
+        std::cout << "sblen: " << sb.str().size() << "\n";
+        std::cout << "sbloc: " << sb.getloc() << "\n";
+        //std::stringbuf sb( iss.str() );
+
         newtag.key   = pmt::deserialize( sb );
         newtag.value = pmt::deserialize( sb );
         newtag.srcid = pmt::deserialize( sb );
+        std::cout << "sblen(after): " << sb.str().size() << "\n";
+        std::cout << "sbloc(after): " << sb.getloc() << "\n";
         tags_out.push_back(newtag);
         iss.str(sb.str());
       }



reply via email to

[Prev in Thread] Current Thread [Next in Thread]