[haiku-commits] r40610 - haiku/trunk/src/kits/media

  • From: jonas@xxxxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Tue, 22 Feb 2011 08:09:15 +0100 (CET)

Author: kirilla
Date: 2011-02-22 08:09:14 +0100 (Tue, 22 Feb 2011)
New Revision: 40610
Changeset: http://dev.haiku-os.org/changeset/40610

Modified:
   haiku/trunk/src/kits/media/MediaFiles.cpp
   haiku/trunk/src/kits/media/MediaNode.cpp
Log:
Unsafe strncpy replaced by strlcpy. CID 2262, 2263, 2262, 2253, 2252, 2251, 
2250, 2249. BUFFER_SIZE_WARNING.

Modified: haiku/trunk/src/kits/media/MediaFiles.cpp
===================================================================
--- haiku/trunk/src/kits/media/MediaFiles.cpp   2011-02-22 06:45:23 UTC (rev 
40609)
+++ haiku/trunk/src/kits/media/MediaFiles.cpp   2011-02-22 07:09:14 UTC (rev 
40610)
@@ -93,7 +93,7 @@
 
        server_get_media_items_request request;
        request.team = BPrivate::current_team();
-       strncpy(request.type, type, B_MEDIA_NAME_LENGTH);
+       strlcpy(request.type, type, B_MEDIA_NAME_LENGTH);
 
        server_get_media_items_reply reply;
        status_t status = QueryServer(SERVER_GET_MEDIA_FILE_ITEMS, &request,
@@ -145,8 +145,8 @@
                return B_BAD_VALUE;
 
        server_get_ref_for_request request;
-       strncpy(request.type, type, B_MEDIA_NAME_LENGTH);
-       strncpy(request.item, item, B_MEDIA_NAME_LENGTH);
+       strlcpy(request.type, type, B_MEDIA_NAME_LENGTH);
+       strlcpy(request.item, item, B_MEDIA_NAME_LENGTH);
 
        server_get_ref_for_reply reply;
        status_t status = QueryServer(SERVER_GET_REF_FOR, &request, 
sizeof(request),
@@ -170,8 +170,8 @@
                return B_BAD_VALUE;
 
        server_get_item_audio_gain_request request;
-       strncpy(request.type, type, B_MEDIA_NAME_LENGTH);
-       strncpy(request.item, item, B_MEDIA_NAME_LENGTH);
+       strlcpy(request.type, type, B_MEDIA_NAME_LENGTH);
+       strlcpy(request.item, item, B_MEDIA_NAME_LENGTH);
 
        server_get_item_audio_gain_reply reply;
        status_t status = QueryServer(SERVER_GET_ITEM_AUDIO_GAIN, &request,
@@ -193,8 +193,8 @@
        CALLED();
 
        server_set_ref_for_request request;
-       strncpy(request.type, type, B_MEDIA_NAME_LENGTH);
-       strncpy(request.item, item, B_MEDIA_NAME_LENGTH);
+       strlcpy(request.type, type, B_MEDIA_NAME_LENGTH);
+       strlcpy(request.item, item, B_MEDIA_NAME_LENGTH);
        request.ref = ref;
 
        server_set_ref_for_reply reply;
@@ -215,8 +215,8 @@
        CALLED();
 
        server_set_item_audio_gain_request request;
-       strncpy(request.type, type, B_MEDIA_NAME_LENGTH);
-       strncpy(request.item, item, B_MEDIA_NAME_LENGTH);
+       strlcpy(request.type, type, B_MEDIA_NAME_LENGTH);
+       strlcpy(request.item, item, B_MEDIA_NAME_LENGTH);
        request.gain = gain;
 
        server_set_item_audio_gain_reply reply;
@@ -238,8 +238,8 @@
        CALLED();
 
        server_invalidate_item_request request;
-       strncpy(request.type, type, B_MEDIA_NAME_LENGTH);
-       strncpy(request.item, item, B_MEDIA_NAME_LENGTH);
+       strlcpy(request.type, type, B_MEDIA_NAME_LENGTH);
+       strlcpy(request.item, item, B_MEDIA_NAME_LENGTH);
 
        server_invalidate_item_reply reply;
        status_t status = QueryServer(SERVER_INVALIDATE_MEDIA_ITEM, &request,
@@ -259,8 +259,8 @@
        CALLED();
 
        server_remove_media_item_request request;
-       strncpy(request.type, type, B_MEDIA_NAME_LENGTH);
-       strncpy(request.item, item, B_MEDIA_NAME_LENGTH);
+       strlcpy(request.type, type, B_MEDIA_NAME_LENGTH);
+       strlcpy(request.item, item, B_MEDIA_NAME_LENGTH);
 
        server_remove_media_item_reply reply;
        status_t status = QueryServer(SERVER_REMOVE_MEDIA_ITEM, &request,

Modified: haiku/trunk/src/kits/media/MediaNode.cpp
===================================================================
--- haiku/trunk/src/kits/media/MediaNode.cpp    2011-02-22 06:45:23 UTC (rev 
40609)
+++ haiku/trunk/src/kits/media/MediaNode.cpp    2011-02-22 07:09:14 UTC (rev 
40610)
@@ -886,10 +886,8 @@
        fNodeID = id;
        fRefCount = 1;
        fName[0] = 0;
-       if (name) {
-               strncpy(fName, name, B_MEDIA_NAME_LENGTH - 1);
-               fName[B_MEDIA_NAME_LENGTH - 1] = 0;
-       }
+       if (name)
+               strlcpy(fName, name, B_MEDIA_NAME_LENGTH);
        fRunMode = B_INCREASE_LATENCY;
        fKinds = kinds;
        fProducerThis = 0;


Other related posts:

  • » [haiku-commits] r40610 - haiku/trunk/src/kits/media - jonas