X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=snapshot-interface.cc;h=fdabcf33549349acb203ac201608461aa25d049c;hb=1f2a30ddc8f38f3f45d62d169b766c0c38364ecd;hp=5f8a68773eeba95fca07678ee73d6e39ace1c62d;hpb=dde52d51d6658cfa908e0b44bc4cc01edd660e9d;p=model-checker.git diff --git a/snapshot-interface.cc b/snapshot-interface.cc index 5f8a687..fdabcf3 100644 --- a/snapshot-interface.cc +++ b/snapshot-interface.cc @@ -85,10 +85,16 @@ static void SnapshotGlobalSegments() static void get_binary_name(char *buf, size_t len) { - if (readlink("/proc/self/exe", buf, len) == -1) { + ssize_t size = readlink("/proc/self/exe", buf, len); + if (size < 0) { perror("readlink"); exit(EXIT_FAILURE); } + + /* Terminate string */ + if ((size_t)size > len) + size = len; + buf[size] = '\0'; } /** The SnapshotGlobalSegments function computes the memory regions