iliaa           Sat Feb 24 17:40:45 2007 UTC

  Modified files:              (Branch: PHP_5_2)
    /php-src/ext/exif   exif.c 
  Log:
  
  Eliminate strncpy and simplify code
  
http://cvs.php.net/viewvc.cgi/php-src/ext/exif/exif.c?r1=1.173.2.5.2.14&r2=1.173.2.5.2.15&diff_format=u
Index: php-src/ext/exif/exif.c
diff -u php-src/ext/exif/exif.c:1.173.2.5.2.14 
php-src/ext/exif/exif.c:1.173.2.5.2.15
--- php-src/ext/exif/exif.c:1.173.2.5.2.14      Sat Feb 24 14:28:09 2007
+++ php-src/ext/exif/exif.c     Sat Feb 24 17:40:45 2007
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: exif.c,v 1.173.2.5.2.14 2007/02/24 14:28:09 helly Exp $ */
+/* $Id: exif.c,v 1.173.2.5.2.15 2007/02/24 17:40:45 iliaa Exp $ */
 
 /*  ToDos
  *
@@ -142,7 +142,7 @@
 };
 /* }}} */
 
-#define EXIF_VERSION "1.4 $Id: exif.c,v 1.173.2.5.2.14 2007/02/24 14:28:09 
helly Exp $"
+#define EXIF_VERSION "1.4 $Id: exif.c,v 1.173.2.5.2.15 2007/02/24 17:40:45 
iliaa Exp $"
 
 /* {{{ PHP_MINFO_FUNCTION
  */
@@ -1002,13 +1002,10 @@
                                break;
                        }
                        if (ret && len)  {
-                               strncpy(ret, tag_table[i].Desc, abs(len));
-                               if (len<0) {
-                                       len = -len;
-                                       ret[len-1]='\0';
-                                       for(i=strlen(ret);i<len;i++)ret[i]=' ';
+                               strlcpy(ret, tag_table[i].Desc, abs(len));
+                               if (len < 0) {
+                                       memset(ret, ' ', -len - 1);
                                }
-                               ret[len-1]='\0';
                                return ret;
                        }
                        return tag_table[i].Desc;
@@ -1016,13 +1013,10 @@
        }
        if (ret && len) {
                snprintf(tmp, sizeof(tmp), "UndefinedTag:0x%04X", tag_num);
-               strncpy(ret, tmp, abs(len));
-               if (len<0) {
-                       len = -len;
-                       ret[len-1]='\0';
-                       for(i=strlen(ret);i<len;i++)ret[i]=' ';
+               strlcpy(ret, tmp, abs(len));
+               if (len < 0) {
+                       memset(ret, ' ', -len - 1);
                }
-               ret[len-1]='\0';
                return ret;
        }
        return "";

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to