$OpenBSD: patch-src_playlist_pm_python_c,v 1.1 2005/05/21 13:46:44 alek Exp $
--- src/playlist/pm_python.c.orig	Thu Mar 24 16:42:00 2005
+++ src/playlist/pm_python.c	Thu Mar 24 18:14:48 2005
@@ -213,13 +213,25 @@ python_init (void)
 static int
 python_setup_path (void)
 {
-  char *oldpath = getenv ("PYTHONPATH");
+  size_t size;
+  int ret;
+  char *oldpath;
 
-  if (oldpath && (python_path = (char*) malloc (strlen(oldpath) + strlen (ICES_MODULEDIR) + 15)))
-    sprintf (python_path, "PYTHONPATH=%s:%s:.", oldpath, ICES_MODULEDIR);
-  else if ((python_path = (char*) malloc (strlen (ICES_MODULEDIR) + 14)))
-    sprintf (python_path, "PYTHONPATH=%s:.", ICES_MODULEDIR);
-  else {
+  oldpath = getenv ("PYTHONPATH");
+
+  if (oldpath && (python_path = (char*) malloc (size = strlen(oldpath) + strlen (ICES_MODULEDIR) + 14 + 1))) {
+    ret = snprintf (python_path, size, "PYTHONPATH=%s:%s:.", oldpath, ICES_MODULEDIR);
+    if (ret == -1 || ret >= size) {
+      ices_log_error ("Truncation or output/encoding error occured while generating Python environment");
+      return -1;
+    }
+  } else if ((python_path = (char*) malloc (size = strlen (ICES_MODULEDIR) + 13 + 1))) {
+    ret = snprintf (python_path, size, "PYTHONPATH=%s:.", ICES_MODULEDIR);
+    if (ret == -1 || ret >= size) {
+      ices_log_error ("Truncation or output/encoding error occured while generating Python environment");
+      return -1;
+    }
+  } else {
     ices_log_error ("Could not allocate memory for python environment");
     return -1;
   }
