[xiph-cvs] cvs commit: vorbis-tools/ogg123 ao_interface.c

Jeff Squyres jsquyres at xiph.org
Mon Feb 19 14:22:29 PST 2001



jsquyres    01/02/19 14:22:28

  Modified:    ogg123   ao_interface.c
  Log:
  Changed NAME_MAX to FILENAME_MAX.  Included <stdio.h> to get the
  definition of it.
  
  Issues:
  
  - FILENAME_MAX is a constant, and may not be safe, because the actual
    max allowable length of a filename varies from filesystem to filesystem.
  - but then again, we're only putting a short file (.ogg123rc) in $HOME,
    so if strlen($HOME) + 11 is longer than the max allowable filename len,
    the user has other, larger problems.
  - pathconf() should be used to reliably get the max allowable filename
    len, but this is not necessarily available on all systems (e.g., some
    windows compilers have it, others don't.  Have no idea about mac
    compilers).  This may not matter, either, though, because ogg123
    is apparently known to only work on certain kinds of systems.
  - this is really only to bound the length of a string, so it may not
    matter anyway (given the assumption that strlen($HOME) + 11 is ok).

Revision  Changes    Path
1.2       +4 -3      vorbis-tools/ogg123/ao_interface.c

Index: ao_interface.c
===================================================================
RCS file: /usr/local/cvsroot/vorbis-tools/ogg123/ao_interface.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ao_interface.c	2000/12/25 22:20:41	1.1
+++ ao_interface.c	2001/02/19 22:22:28	1.2
@@ -1,3 +1,4 @@
+#include <stdio.h>
 #include <string.h>
 #include <limits.h>
 
@@ -58,7 +59,7 @@
 int get_default_device(void)
 {
     FILE *fp;
-    char filename[NAME_MAX];
+    char filename[FILENAME_MAX];
     char line[100];
     char *device = NULL;
     char *homedir = getenv("HOME");
@@ -66,10 +67,10 @@
 
     /* Maybe I'm being extremely paranoid, but if ogg123 is ever suid
        root (to access audio devices), this is a possible buffer overflow. */
-    if (homedir == NULL || strlen(homedir) >= NAME_MAX - 10)
+    if (homedir == NULL || strlen(homedir) >= FILENAME_MAX - 10)
         return -1;
 
-    strncpy(filename, homedir, NAME_MAX);
+    strncpy(filename, homedir, FILENAME_MAX);
     strcat(filename, "/.ogg123rc");
 
 

--- >8 ----
List archives:  http://www.xiph.org/archives/
Ogg project homepage: http://www.xiph.org/ogg/
To unsubscribe from this list, send a message to 'cvs-request at xiph.org'
containing only the word 'unsubscribe' in the body.  No subject is needed.
Unsubscribe messages sent to the list will be ignored/filtered.



More information about the commits mailing list