]> arthur.barton.de Git - netatalk.git/commitdiff
Abbreviate Netatalk in version string as necessary so that the version number isn...
authorFrank Lahm <franklahm@googlemail.com>
Wed, 20 Jul 2011 09:28:19 +0000 (11:28 +0200)
committerFrank Lahm <franklahm@googlemail.com>
Wed, 20 Jul 2011 09:28:19 +0000 (11:28 +0200)
etc/afpd/status.c

index ae51d26e28cc7fa973d133858f208fb761866d35..f7455a0e1979602093dbfec99a577ee0effb1d37 100644 (file)
@@ -128,15 +128,27 @@ static void status_machine(char *data)
 #ifdef AFS
     const char         *machine = "afs";
 #else /* !AFS */
-    const char         *machine = "Netatalk %s";
+    const char         *machine = "Netatalk%s";
 #endif /* AFS */
     char buf[AFPSTATUS_MACHLEN+1];
 
     memcpy(&status, start + AFPSTATUS_MACHOFF, sizeof(status));
     data += ntohs( status );
 
-    //    len = strlen( machine );
-    len = snprintf(buf, AFPSTATUS_MACHLEN+1, machine, VERSION);
+    if ((strlen(machine) + strlen(VERSION)) <= 16) {
+        len = snprintf(buf, AFPSTATUS_MACHLEN + 1, machine, VERSION);
+    } else {
+        if (strlen(VERSION) > 16) {
+            len = snprintf(buf, AFPSTATUS_MACHLEN + 1, VERSION);
+        } else {
+            (void)snprintf(buf, AFPSTATUS_MACHLEN + 1, machine, "");
+            (void)snprintf(buf + AFPSTATUS_MACHLEN - strlen(VERSION),
+                           strlen(VERSION) + 1,
+                           VERSION);
+            len = AFPSTATUS_MACHLEN;
+        }
+    }
+
     *data++ = len;
     memcpy( data, buf, len );
     data += len;