[haiku-commits] haiku: hrev49129 - in src: add-ons/kernel/file_systems/iso9660 add-ons/screen_savers/spider tools/locale

  • From: pulkomandy@xxxxxxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Tue, 28 Apr 2015 22:23:27 +0200 (CEST)

hrev49129 adds 3 changesets to branch 'master'
old head: 7c52cca9386e8185137e1eb2f3e1a938301fe57f
new head: 4b4a2b684ca341cbbb2a7d217833b639ea60cc79
overview:
http://cgit.haiku-os.org/haiku/log/?qt=range&q=4b4a2b684ca3+%5E7c52cca9386e

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

7dc68bfba5c7: iso9660: fix PVS 2430 to 2435.

* Incorrect handling of realloc() failure (if reallocation fails,
original buffer is still allocated and must be freed),
* Use of bit shift on signed integer (undefined behavior in C and C++).

ad077e2bd2b9: SpiderSaver: PVS 2044.

Missing std::nothrow.

4b4a2b684ca3: Collectcatkeys: PVS1632: unsafe fprintf (harmless).

[ Adrien Destugues <pulkomandy@xxxxxxxxx> ]

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

3 files changed, 48 insertions(+), 25 deletions(-)
.../kernel/file_systems/iso9660/iso9660.cpp | 44 +++++++++++++-------
src/add-ons/screen_savers/spider/SpiderSaver.cpp | 24 +++++++----
src/tools/locale/collectcatkeys.cpp | 5 +--

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

Commit: 7dc68bfba5c728128e0a98d6804fbea34f6153a7
URL: http://cgit.haiku-os.org/haiku/commit/?id=7dc68bfba5c7
Author: Adrien Destugues <pulkomandy@xxxxxxxxx>
Date: Tue Apr 28 19:49:23 2015 UTC

iso9660: fix PVS 2430 to 2435.

* Incorrect handling of realloc() failure (if reallocation fails,
original buffer is still allocated and must be freed),
* Use of bit shift on signed integer (undefined behavior in C and C++).

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

diff --git a/src/add-ons/kernel/file_systems/iso9660/iso9660.cpp
b/src/add-ons/kernel/file_systems/iso9660/iso9660.cpp
index bbe2685..f02a22c 100644
--- a/src/add-ons/kernel/file_systems/iso9660/iso9660.cpp
+++ b/src/add-ons/kernel/file_systems/iso9660/iso9660.cpp
@@ -307,6 +307,7 @@ parse_rock_ridge(iso9660_volume* volume, iso9660_inode*
node, char* buffer,
// Now we're at the start of the rock ridge stuff
char* altName = NULL;
char* slName = NULL;
+ char* newSlName = NULL;
uint16 altNameSize = 0;
uint16 slNameSize = 0;
uint8 length = 0;
@@ -410,10 +411,13 @@ parse_rock_ridge(iso9660_volume* volume, iso9660_inode*
node, char* buffer,
slNameSize += compLen;
if (useSeparator)
slNameSize++;
- slName =
(char*)realloc(slName,
+ newSlName =
(char*)realloc(slName,
slNameSize + 1);
- if (slName == NULL)
+ if (newSlName == NULL) {
+ free(slName);
return
B_NO_MEMORY;
+ }
+ slName = newSlName;

if (useSeparator) {
TRACE(("Adding
separator\n"));
@@ -431,10 +435,13 @@ parse_rock_ridge(iso9660_volume* volume, iso9660_inode*
node, char* buffer,
case SLCP_CURRENT:
TRACE(("InitNode -
found link to current directory\n"));
slNameSize += 2;
- slName =
(char*)realloc(slName,
+ newSlName =
(char*)realloc(slName,
slNameSize + 1);
- if (slName == NULL)
+ if (newSlName == NULL) {
+ free(slName);
return
B_NO_MEMORY;
+ }
+ slName = newSlName;

memcpy(slName + addPos,
"./", 2);
useSeparator = false;
@@ -442,10 +449,13 @@ parse_rock_ridge(iso9660_volume* volume, iso9660_inode*
node, char* buffer,

case SLCP_PARENT:
slNameSize += 3;
- slName =
(char*)realloc(slName,
+ newSlName =
(char*)realloc(slName,
slNameSize + 1);
- if (slName == NULL)
+ if (newSlName == NULL) {
+ free(slName);
return
B_NO_MEMORY;
+ }
+ slName = newSlName;

memcpy(slName + addPos,
"../", 3);
useSeparator = false;
@@ -454,10 +464,13 @@ parse_rock_ridge(iso9660_volume* volume, iso9660_inode*
node, char* buffer,
case SLCP_ROOT:
TRACE(("InitNode -
found link to root directory\n"));
slNameSize += 1;
- slName =
(char*)realloc(slName,
+ newSlName =
(char*)realloc(slName,
slNameSize + 1);
- if (slName == NULL)
+ if (newSlName == NULL) {
+ free(slName);
return
B_NO_MEMORY;
+ }
+ slName = newSlName;
memcpy(slName + addPos,
"/", 1);
useSeparator = false;
break;
@@ -488,16 +501,20 @@ parse_rock_ridge(iso9660_volume* volume, iso9660_inode*
node, char* buffer,
uint16 oldEnd = altNameSize;

altNameSize += length - 5;
- altName = (char*)realloc(altName, altNameSize +
1);
- if (altName == NULL)
+ char* newAltName = (char*)realloc(altName,
altNameSize + 1);
+ if (newAltName == NULL) {
+ free(altName);
return B_NO_MEMORY;
+ }
+ altName = newAltName;

TRACE(("RR: found NM, length %u\n", length));
// Read flag and version.
node->attr.nmVer = *(uint8 *)(buffer +
bytePos++);
flags = *(uint8 *)(buffer + bytePos++);

- TRACE(("RR: nm buffer is %s, start at %p\n",
(buffer + bytePos), buffer + bytePos));
+ TRACE(("RR: nm buffer is %s, start at %p\n",
(buffer + bytePos),
+ buffer + bytePos));

// Build the file name.
memcpy(altName + oldEnd, buffer + bytePos,
length - 5);
@@ -973,7 +990,8 @@ status_t
ConvertRecDate(ISORecDate* inDate, time_t* outDate)
{
time_t time;
- int days, i, year, tz;
+ int days, i, year;
+ int8_t tz;

year = inDate->year - 70;
tz = inDate->offsetGMT;
@@ -998,8 +1016,6 @@ ConvertRecDate(ISORecDate* inDate, time_t* outDate)
days += inDate->date - 1;
time = ((((days*24) + inDate->hour) * 60 + inDate->minute) * 60)
+ inDate->second;
- if (tz & 0x80)
- tz |= (-1 << 8);

if (-48 <= tz && tz <= 52)
time -= tz * 15 * 60;

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

Commit: ad077e2bd2b98ac409308948dc45a85a3c25049d
URL: http://cgit.haiku-os.org/haiku/commit/?id=ad077e2bd2b9
Author: Adrien Destugues <pulkomandy@xxxxxxxxx>
Date: Tue Apr 28 20:00:32 2015 UTC

SpiderSaver: PVS 2044.

Missing std::nothrow.

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

diff --git a/src/add-ons/screen_savers/spider/SpiderSaver.cpp
b/src/add-ons/screen_savers/spider/SpiderSaver.cpp
index 7a78faf..eddc571 100644
--- a/src/add-ons/screen_savers/spider/SpiderSaver.cpp
+++ b/src/add-ons/screen_savers/spider/SpiderSaver.cpp
@@ -213,14 +213,12 @@ SpiderSaver::_Init(BRect bounds)
maxQueueDepth /= 4;
}
for (uint32 i = 0; i < fQueueNumber; i++)
- fQueues[i] = new PolygonQueue(new Polygon(bounds, minPoints
-
+ lrand48()
-
% (maxPoints
-
- minPoints)),
-
minQueueDepth + lrand48() % (maxQueueDepth
- -
minQueueDepth));
+ fQueues[i] = new PolygonQueue(new Polygon(bounds,
+ minPoints + lrand48() % (maxPoints - minPoints)),
+ minQueueDepth + lrand48() % (maxQueueDepth -
minQueueDepth));
}

+
// _Cleanup
void
SpiderSaver::_Cleanup()
@@ -232,6 +230,7 @@ SpiderSaver::_Cleanup()
}
}

+
// _AllocBackBitmap
void
SpiderSaver::_AllocBackBitmap(float width, float height)
@@ -241,11 +240,18 @@ SpiderSaver::_AllocBackBitmap(float width, float height)
return;

BRect b(0.0, 0.0, width, height);
- fBackBitmap = new BBitmap(b, B_RGB32, true);
+ fBackBitmap = new(std::nothrow) BBitmap(b, B_RGB32, true);
if (!fBackBitmap)
return;
+
if (fBackBitmap->IsValid()) {
- fBackView = new BView(b, 0, B_FOLLOW_NONE, B_WILL_DRAW);
+ fBackView = new(std::nothrow) BView(b, 0, B_FOLLOW_NONE,
B_WILL_DRAW);
+ if (fBackView == NULL) {
+ _FreeBackBitmap();
+ fprintf(stderr,
+ "SpiderSaver::_AllocBackBitmap(): view
allocation failed\n");
+ return;
+ }
fBackBitmap->AddChild(fBackView);
memset(fBackBitmap->Bits(), 0, fBackBitmap->BitsLength());
} else {
@@ -254,6 +260,7 @@ SpiderSaver::_AllocBackBitmap(float width, float height)
}
}

+
// _FreeBackBitmap
void
SpiderSaver::_FreeBackBitmap()
@@ -265,6 +272,7 @@ SpiderSaver::_FreeBackBitmap()
}
}

+
// _DrawInto
void
SpiderSaver::_DrawInto(BView *view)

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

Revision: hrev49129
Commit: 4b4a2b684ca341cbbb2a7d217833b639ea60cc79
URL: http://cgit.haiku-os.org/haiku/commit/?id=4b4a2b684ca3
Author: Adrien Destugues <pulkomandy@xxxxxxxxx>
Date: Tue Apr 28 20:08:34 2015 UTC

Collectcatkeys: PVS1632: unsafe fprintf (harmless).

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

diff --git a/src/tools/locale/collectcatkeys.cpp
b/src/tools/locale/collectcatkeys.cpp
index 6430c30..78ded2d 100644
--- a/src/tools/locale/collectcatkeys.cpp
+++ b/src/tools/locale/collectcatkeys.cpp
@@ -57,7 +57,7 @@ usage()
" -r <regex>\t\tchanges the regex used by the key-scanner to
the one "
"given,\n"
" \t\t\tthe default is: ");
- fprintf(stderr, rxString.String());
+ fprintf(stderr, "%s", rxString.String());
fprintf(stderr,"\n -s <catalogSig>\tsignature of the
target-catalog\n"
" -v\t\t\tbe verbose, show summary\n"
" -w\t\t\tshow warnings about catalog-accesses that couldn't
be "
@@ -247,8 +247,7 @@ main(int argc, char **argv)
else if (c == 'o') {
outputFile = (++argv)[0];
break;
- }
- else if (c == 'r') {
+ } else if (c == 'r') {
rxString = (++argv)[0];
break;
}


Other related posts:

  • » [haiku-commits] haiku: hrev49129 - in src: add-ons/kernel/file_systems/iso9660 add-ons/screen_savers/spider tools/locale - pulkomandy