[Bf-committers] [PATCH] Patch to storage.c to avoid crash on long userids

Jochen Schmitt Jochen at herr-schmitt.de
Sun Mar 28 19:39:31 CEST 2010


Hallo,

on

https://bugzilla.redhat.com/show_bug.cgi?id=572186

an user complains a crash which seems to occured, if he use
an userid which contains more the 15 characters. I have found
a line in the file storage.c where an userid which will be returned
by the getpwent() function. This userid will been copied into an array
which is declared as char [16]. Unfortunately on Fedora you can create
an userid which will be contains more then 16 characters. So I have to
replace the strcpy() function to strncpy() to make sure, that not more then
16 characters will been copied even if the userid should be have more
the 16 characters.

It may be nice, if anyone can do a review of this patch for inclussion into
the main blender development branch.

Best Regards:

Jochen Schmitt


diff -up blender/source/blender/blenlib/intern/storage.c.uid
blender/source/blender/blenlib/intern/storage.c
--- blender/source/blender/blenlib/intern/storage.c.uid 2010-03-28
19:18:49.511022187 +0200
+++ blender/source/blender/blenlib/intern/storage.c     2010-03-28
19:20:37.773022342 +0200
@@ -331,7 +331,8 @@ void BLI_adddirstrings()
                        struct passwd *pwuser;
                        pwuser = getpwuid(files[num].s.st_uid);
                        if ( pwuser ) {
-                       strcpy(files[num].owner, pwuser->pw_name);
+                         strncpy(files[num].owner, pwuser->pw_name, 15);
+                          files[num].owner[15] = '\0';
                        } else {
                                sprintf(files[num].owner, "%d",
files[num].s.st_uid);
                        }
~
~



More information about the Bf-committers mailing list