[haiku-commits] haiku: hrev53285 - in src: tools/gensyscalls bin bin/pc libs/bsd

  • From: waddlesplash <waddlesplash@xxxxxxxxx>
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Sun, 21 Jul 2019 16:05:19 -0400 (EDT)

hrev53285 adds 2 changesets to branch 'master'
old head: 319c399d61497d2e6dbca0ffae8d5d2a2d72d866
new head: 91ec679f17eac49beb7356ef0eaa39df099fd639
overview: 
https://git.haiku-os.org/haiku/log/?qt=range&q=91ec679f17ea+%5E319c399d6149

----------------------------------------------------------------------------

a63a6eb9bcd0: PVS V1022 throwing exceptions by pointer
  
  Change-Id: I0767da0be63a2955cc370ee81dc921cdf101285e
  Reviewed-on: https://review.haiku-os.org/c/1638
  Reviewed-by: waddlesplash <waddlesplash@xxxxxxxxx>

91ec679f17ea: PVS V1010: access before start of buffer after fgets
  
  Change-Id: I8cfa1e8a3c8dd8c2837e51756ac3eeaea1e756f0
  Reviewed-on: https://review.haiku-os.org/c/1639
  Reviewed-by: waddlesplash <waddlesplash@xxxxxxxxx>

                             [ Adrien Destugues <pulkomandy@xxxxxxxxxxxxx> ]

----------------------------------------------------------------------------

4 files changed, 10 insertions(+), 8 deletions(-)
src/bin/mimeset.cpp                       | 6 ++++--
src/bin/pc/pc.c                           | 2 +-
src/libs/bsd/getpass.c                    | 2 +-
src/tools/gensyscalls/gensyscallinfos.cpp | 8 ++++----

############################################################################

Commit:      a63a6eb9bcd0465900f29bf9c7fd083f6f203952
URL:         https://git.haiku-os.org/haiku/commit/?id=a63a6eb9bcd0
Author:      Adrien Destugues <pulkomandy@xxxxxxxxxxxxx>
Date:        Sun Jul 21 17:41:13 2019 UTC
Committer:   waddlesplash <waddlesplash@xxxxxxxxx>
Commit-Date: Sun Jul 21 20:05:08 2019 UTC

PVS V1022 throwing exceptions by pointer

Change-Id: I0767da0be63a2955cc370ee81dc921cdf101285e
Reviewed-on: https://review.haiku-os.org/c/1638
Reviewed-by: waddlesplash <waddlesplash@xxxxxxxxx>

----------------------------------------------------------------------------

diff --git a/src/tools/gensyscalls/gensyscallinfos.cpp 
b/src/tools/gensyscalls/gensyscallinfos.cpp
index cf82831459..b94a1dd84c 100644
--- a/src/tools/gensyscalls/gensyscallinfos.cpp
+++ b/src/tools/gensyscalls/gensyscallinfos.cpp
@@ -313,7 +313,7 @@ private:
                // open the input file
                ifstream file(filename, ifstream::in);
                if (!file.is_open())
-                       throw new IOException(string("Failed to open `") + 
filename + "'.");
+                       throw IOException(string("Failed to open `") + filename 
+ "'.");
                // parse the syscalls
                Tokenizer tokenizer(file);
                // find "#pragma syscalls begin"
@@ -344,7 +344,7 @@ private:
                // open the syscall info file
                ofstream file(filename, ofstream::out | ofstream::trunc);
                if (!file.is_open())
-                       throw new IOException(string("Failed to open `") + 
filename + "'.");
+                       throw IOException(string("Failed to open `") + filename 
+ "'.");
 
                // write preamble
                file << "#include \"gensyscalls.h\"" << endl;
@@ -410,7 +410,7 @@ private:
                // open the syscall info file
                ofstream file(filename, ofstream::out | ofstream::trunc);
                if (!file.is_open())
-                       throw new IOException(string("Failed to open `") + 
filename + "'.");
+                       throw IOException(string("Failed to open `") + filename 
+ "'.");
 
                // write preamble
                file << "#include <computed_asm_macros.h>" << endl;
@@ -569,7 +569,7 @@ main(int argc, char** argv)
 {
        try {
                return Main().Run(argc, argv);
-       } catch (Exception& exception) {
+       } catch (const Exception& exception) {
                fprintf(stderr, "%s\n", exception.what());
                return 1;
        }

############################################################################

Revision:    hrev53285
Commit:      91ec679f17eac49beb7356ef0eaa39df099fd639
URL:         https://git.haiku-os.org/haiku/commit/?id=91ec679f17ea
Author:      Adrien Destugues <pulkomandy@xxxxxxxxxxxxx>
Date:        Sun Jul 21 17:52:29 2019 UTC
Committer:   waddlesplash <waddlesplash@xxxxxxxxx>
Commit-Date: Sun Jul 21 20:05:08 2019 UTC

PVS V1010: access before start of buffer after fgets

Change-Id: I8cfa1e8a3c8dd8c2837e51756ac3eeaea1e756f0
Reviewed-on: https://review.haiku-os.org/c/1639
Reviewed-by: waddlesplash <waddlesplash@xxxxxxxxx>

----------------------------------------------------------------------------

diff --git a/src/bin/mimeset.cpp b/src/bin/mimeset.cpp
index b83b4a96f9..263bdefe32 100644
--- a/src/bin/mimeset.cpp
+++ b/src/bin/mimeset.cpp
@@ -238,8 +238,10 @@ main(int argc, const char** argv)
                        // read file names from stdin
                        char name[B_PATH_NAME_LENGTH];
                        while (fgets(name, sizeof(name), stdin) != NULL) {
-                               name[strlen(name) - 1] = '\0';
-                                       // remove trailing '\n'
+                               if (name[0] != '\0') {
+                                       name[strlen(name) - 1] = '\0';
+                                               // remove trailing '\n'
+                               }
                                if (process_file(name) != B_OK)
                                        exit(1);
                        }
diff --git a/src/bin/pc/pc.c b/src/bin/pc/pc.c
index 05fb9123f1..92d6e8161f 100644
--- a/src/bin/pc/pc.c
+++ b/src/bin/pc/pc.c
@@ -284,7 +284,7 @@ do_input(void)
   
   while(fgets(buff, 256, stdin) != NULL)
    {
-     if (buff[strlen(buff)-1] == '\n')
+     if (buff[0] != '\0' && buff[strlen(buff)-1] == '\n')
        buff[strlen(buff)-1] = '\0';     /* kill the newline character */
 
      for(ptr=buff; isspace(*ptr) && *ptr; ptr++)
diff --git a/src/libs/bsd/getpass.c b/src/libs/bsd/getpass.c
index 45676c0b3e..65485ceadb 100644
--- a/src/libs/bsd/getpass.c
+++ b/src/libs/bsd/getpass.c
@@ -38,7 +38,7 @@ getpass(const char *prompt)
        if (fgets(password, sizeof(password), stdin) != NULL) {
                size_t length = strlen(password);
 
-               if (password[length - 1] == '\n')
+               if (length > 0 && (password[length - 1] == '\n'))
                        password[length - 1] = '\0';
 
                if (changed) {


Other related posts:

  • » [haiku-commits] haiku: hrev53285 - in src: tools/gensyscalls bin bin/pc libs/bsd - waddlesplash